Sub 查找相同字符个数()
Text = InputBox("请输入您要查找到字符:", "信息提示")
Dim result As String
For i = 1 To 45
Text = "[" + Trim(str(i)) + "]" '注意数值转成字符串会在前面加上空格,所以要用trim去除空格
Text = Trim(Text)
With ActiveDocument.Content.Find
Do While .Execute(FindText:=Text) = True
tim = tim + 1
Loop
End With
'输出到字符串
result = result + Text + "," + str(tim) + ";"
tim = 0
Next i
'将结果写入到文本文件
Call Write2Txt(result, "d:/24.txt")
End Sub
'fileAdress 如 C:/FSOTest/TestFile.txt
Function Write2Txt(str As String, fileAdress As String)
Dim sFile As Object, fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set sFile = fso.CreateTextFile(fileAdress, True)
sFile.WriteLine (str)
sFile.Close
Set sFile = Nothing
Set fso = Nothing
End Function
如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!
txttool.com 说一段 esp56物联 查询128 IP查询