- Set FSO = CreateObject("Scripting.FileSystemObject")
- Set File = FSO.OpenTextFile("a.txt",1)
- Do Until File.AtEndOfStream
- A = Split(File.ReadLine,":")
- If Trim(A(0)) = "周长" Then L1 = L1 + CSng(A(1))
- If Trim(A(0)) = "长度" Then L2 = L2 + CSng(A(1))
- Loop
- MsgBox "周长总和:" & L1 & vbCrLf & "长度总和:" & L2
复制代码 保存为vbs,与a.txt放在同一位置,试试 |