本帖最后由 ArdentMan 于 2011-7-2 11:27 编辑
- Dim FSO, Arr1, Str1, Arr2, Str2, Arr3, Number, Total, Answer
- Dim Num(2)
- Set FSO = CreateObject("Scripting.FileSystemObject")
- Arr1 = Split(FSO.OpenTextFile("a.txt").ReadAll(), vbCrLf)
- For Each Str1 In Arr1
- If Str1 <> vbNullString Then
- Arr2 = Split(Str1, Space(1)) : i = -1
- For Each Str2 In Arr2
- i = i + 1
- Arr3 = Split(Str2, ".")
- Num(i) = Arr3(0) * 256 * 256 * 256 + Arr3(1) * 256 * 256 + Arr3(2) * 256 + Arr3(3)
- Answer = Answer & Str2 & vbTab
- Next
- Number = Num(1) - Num(0) + 1
- Total = Total + Number
- Answer = Answer & "小计" & Number & "个" & vbCrLf
- End If
- Next
- Answer = Answer & String(45, "-") & vbCrLf & "统计结果总数为:" & Total & "个"
- FSO.OpenTextFile ("a.txt", 2, True).Write Answer
- Set FSO = Nothing
- CreateObject("Wscript.Shell").Run("a.txt")
复制代码
|