统计某个单词出现次数

'引用Microsoft VBScript Regular Expressions 1.0

'统计单词出现次数 Private Function TongJi(ByVal T_txt As String) As Long Dim cnt As Long Dim re As RegExp Dim mhs As MatchCollection Set re = New RegExp re.IgnoreCase = False re.Global = True Dim strLine As String Open "C:\1.log" For Input As #1 Do Until EOF(1) Line Input #1, strLine re.Pattern = T_txt Set mhs = re.Execute(strLine) cnt = cnt + mhs.Count Loop Close #1 TongJi = cnt End Function Private Sub Command1_Click() Dim e As Long e = TongJi(Text1.Text) Cls List1.AddItem Text1.Text & " 出现过: " & e & " 次" End Sub

 

posted @ 2013-03-13 17:26  habin  阅读(385)  评论(0编辑  收藏  举报