当前位置:DOS资源站资料中心VBS脚本 → vbs实现统计字符模块

vbs实现统计字符模块

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2008-4-9 22:41:15

Sub TongJi()
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("ok.txt", 1)
strText = objFile.ReadAll
All = Len(strText)
S="` ~ ! @ # $ % ^ & * ( ) - _ = + \ | [ { ] } ; : ' , < . > / ? · ! ¥ ( ) 、 【 】 ; : ‘ ’ “ ” , 《 。 》 ? …… —— chr(34) vbCrLf"
Signs=Split(S," ")
For Each Sign in Signs
strText = Replace(strText, "Sign", " ")
Next
objFile.Close
For k=1 To Len(strText)
tmpStr=Mid(strText, k, 1)
If Asc(tmpStr) > 127 Or Asc(tmpStr) < 0 Then
c = c + 1
tmpStr=" "
End If
Str = Str + tmpStr
Next
arrWords = Split(Str, " ")
For Each strWord in arrWords
If Len(strWord) > 0 Then
i = i + 1
End If
Next
Sum = c + i
msgbox "字符总数:" & All & chr(13) & "有效字符:" & Sum & chr(13) & "汉字总数:" & c, 64, "字符统计"
End sub