我正在尝试阅读文本文件并计算文本文件中出现短语/字符串(不是单词)的次数,但到目前为止我所拥有的是:
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("D:\VBscript project\testing.txt", ForReading)
strContents = objFile.ReadAll
objFile.Close
i = 0
arrLines = Split(strContents, "")
For Each strLine in arrLines
If InStr(strLine, "hi there") Then
i = i + 1
End If
Next
WScript.Echo "Number of times word occurs: " & i
Run Code Online (Sandbox Code Playgroud)
这只会让我计算一个单词出现的次数,当我尝试调整它来计算短语时,这不起作用。