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集合对象来过滤重复。



上一篇: javascript正则表达式去除html中的style样式
下一篇: centos lnmp “.user.ini”无法删除解决方法
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: vb
相关日志:
评论: 0 | 引用: 0 | 查看次数: 430
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 关闭

 广告位

↑返回顶部↑