预览模式: 普通 | 列表

centos lnmp “.user.ini”无法删除解决方法

VB6 Collection实现百万文本去重

 

ASP/Visual Basic代码
  1. Option Explicit  
  2.   
  3. '//By: InkHin  
  4.   
  5. '// 参考:https://bbs.csdn.net/topics/350065116  
  6.   
  7. '引用:Microsoft scriptiong Runtime  
  8.   
  9. '感谢 析弱大叔 qq: 1265382638  的指点.  
  10.   
  11. '// 2019-03-10  
  12.   
  13.   
  14. '// 测试 Collection 去重 百万条文本数据过滤  
  15.   
  16. '// 请编译执行  
  17.   
  18. Private Function Out_Remove_Same(ByVal Path As StringByVal InName As StringByVal OutName As String)  
  19. Dim col As Collection  
  20.     Set col = New Collection  
  21.     Dim fso As Variant  
  22.     Set fso = CreateObject("Scripting.FileSystemObject")  
  23.     Dim stream1 As Scripting.TextStream  
  24.       
  25.     'Function BuildPath(Path As String, Name As String) As String  '目录路径 文件名称  
  26.       
  27.     Set stream1 = fso.OpenTextFile(fso.BuildPath(Path, InName), ForReading, False)  
  28.       
  29.     Dim stream2 As Scripting.TextStream  
  30.       
  31.     Set stream2 = fso.OpenTextFile(fso.BuildPath(Path, OutName), ForWriting, True)  
  32.       
  33.     While Not stream1.AtEndOfStream  
  34.         Dim strLine As String  
  35.         strLine = stream1.ReadLine  
  36.           
  37.         Dim vntValue As Variant  
  38.         vntValue = Empty  
  39.           
  40.         On Error Resume Next  
  41.         vntValue = col.Item(strLine)  
  42.         On Error GoTo 0  
  43.           
  44.         If IsEmpty(vntValue) Then  
  45.             Call col.Add(Null, strLine)  
  46.             Call stream2.WriteLine(strLine)  
  47.         End If  
  48.     Wend  
  49.       
  50.     Call stream1.Close  
  51.     Call stream2.Close  
  52. End Function  

通过Collection集合对象来过滤重复。

Tags: vb

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 430

 广告位

↑返回顶部↑