[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 pcl_test 于 2015-7-13 17:03 编辑

提取规则是什么,38.00000 |  46.00000是固定的吗?而且只有一个吗?如果不是,说清楚提取规则

TOP

本帖最后由 pcl_test 于 2015-7-13 18:38 编辑
  1. Dim fso,File1',File2
  2. Set fso = CreateObject("Scripting.FileSystemObject")
  3. Set File1= fso.OpenTextFile(".\测试.txt", 1)
  4. 'Set File2 = fso.CreateTextFile(".\结果.txt", 2 ,False)  
  5. Do While File1.AtEndOfStream <> True
  6.     str = File1.ReadLine
  7.     If Left(str,10)="#328612167" Then
  8.     def = 1
  9.     End If
  10.     arr = split(str,"|")
  11.     If ubound(arr) > 6 Then
  12.     a = Trim(arr(4))
  13.     b = Trim(arr(5))
  14.     a1 = split(a,".")
  15.     b1 = split(b,".")
  16.     If def=1 and a1(0)="38"and b1(0)="46" and IsNumeric(a) and IsNumeric(b) Then
  17.     msgbox arr(1)
  18.     'File2.WriteLine arr(1)
  19.     Wscript.Quit
  20.     End If
  21.     End If
  22. loop
复制代码

TOP

回复 5# 328612167

已修改

TOP

回复 8# 328612167


从哪行开始,开头还是#328612167之后

TOP

本帖最后由 pcl_test 于 2015-7-14 20:34 编辑

回复 10# 328612167

本版规则
1、求助时,务必在顶楼一次性把问题交代清楚,建议给出完整有针对性的样本,样本过大可发网盘分享链接。勿发无意义的标题
2、使用 code 标记把代码部分括起来(选中代码后,单击回复框的 <> 按钮),以便复制。问题解决后,请编辑顶楼帖子在标题前面注明[已解决]
  1. Dim fso,File1,File2,str,txt,arr,Dict
  2. Set Dict = CreateObject("Scripting.Dictionary")
  3. Set fso = CreateObject("Scripting.FileSystemObject")
  4. Set File1 = fso.OpenTextFile(".\测试.txt", 1)
  5. Set File2 = fso.CreateTextFile(".\结果.txt", 2 ,False)
  6. n = 1000
  7. Do While File1.AtEndOfStream <> True
  8.     str = File1.ReadLine
  9.     txt = txt&str&vbCrLf
  10.     If Left(str,10)="#328612167" Then def = 1
  11.     arr = split(str,"|")
  12.     If ubound(arr) > 6 Then
  13.         If def=1 and Dict.Exists(arr(1)) <> True Then
  14.               n=n+1
  15.               Dict.Add arr(1), rtrim(arr(1))&"-A"&right(n,3)&" "
  16.         End If
  17.     End If
  18. Loop
  19. Dim tmp,objKeys,objItems
  20. objKeys = Dict.Keys
  21. objItems = Dict.Items
  22. For i = 0 To Dict.Count -1
  23.     tmp = replace(txt,objKeys(i),objItems(i))
  24.     txt = tmp
  25. Next
  26. File2.Write txt
  27. File1.Close
  28. File2.Close
  29. Dict.RemoveAll
  30. Set Dict = Nothing
  31. Msgbox "完成"
复制代码
1

评分人数

TOP

返回列表