主题:呃,本人新手...程序求解
Dim myRegExp As Object
Dim myMatches As MatchCollection
Dim myMatch As Match
Dim ai As String
Dim wds(10000) As String, wf(10000) As Integer, nwd As Integer
Private Sub Form_Load()
Set myRegExp = New VBScript_RegExp_55.RegExp
myRegExp.IgnoreCase = True
myRegExp.Global = True
myRegExp.Pattern = "\w+"
End Sub
Private Sub Text1_Change()
Dim a As String, i As Integer, j As Integer, f As Integer
s = Text1.Text
Set myMatches = myRegExp.Execute(s)
nwd = 0
For Each myMatch In myMatches
a = LCase(myMatch.Value)
If InStr(ai, "," & a & ",") = 0 Then
If nwd = 0 Then
wds(nwd) = a
wf(nwd) = 1
nwd = nwd + 1
Else
For i = 0 To nwd - 1
If wds(i) = LCase(a) Then
wf(i) = wf(i) + 1
Exit For
End If
Next i
If i = nwd Then
wds(nwd) = LCase(a)
wf(nwd) = 1
nwd = nwd + 1
Else
If i > 0 Then
f = wf(i)
a = wds(i)
For j = i - 1 To 0 Step -1
If f < wf(j) Then Exit For
wds(j + 1) = wds(j)
wf(j + 1) = wf(j)
wds(j) = a
wf(j) = f
Next j
End If
End If
End If
End If
Next
If nwd > 0 Then
For i = 0 To nwd
If i = 0 Then
Label3.Caption = " 1: " & wds(i) & " " & wf(i)
Else
Label3.Caption = Label3.Caption & Chr(13) & " " & CStr(i + 1) & ": " & wds(i) & " " & wf(i)
End If
If i = 4 Then Exit For
Next i
End If
End Sub
麻烦懂的帮忙解释下...谢谢
Dim myMatches As MatchCollection
Dim myMatch As Match
Dim ai As String
Dim wds(10000) As String, wf(10000) As Integer, nwd As Integer
Private Sub Form_Load()
Set myRegExp = New VBScript_RegExp_55.RegExp
myRegExp.IgnoreCase = True
myRegExp.Global = True
myRegExp.Pattern = "\w+"
End Sub
Private Sub Text1_Change()
Dim a As String, i As Integer, j As Integer, f As Integer
s = Text1.Text
Set myMatches = myRegExp.Execute(s)
nwd = 0
For Each myMatch In myMatches
a = LCase(myMatch.Value)
If InStr(ai, "," & a & ",") = 0 Then
If nwd = 0 Then
wds(nwd) = a
wf(nwd) = 1
nwd = nwd + 1
Else
For i = 0 To nwd - 1
If wds(i) = LCase(a) Then
wf(i) = wf(i) + 1
Exit For
End If
Next i
If i = nwd Then
wds(nwd) = LCase(a)
wf(nwd) = 1
nwd = nwd + 1
Else
If i > 0 Then
f = wf(i)
a = wds(i)
For j = i - 1 To 0 Step -1
If f < wf(j) Then Exit For
wds(j + 1) = wds(j)
wf(j + 1) = wf(j)
wds(j) = a
wf(j) = f
Next j
End If
End If
End If
End If
Next
If nwd > 0 Then
For i = 0 To nwd
If i = 0 Then
Label3.Caption = " 1: " & wds(i) & " " & wf(i)
Else
Label3.Caption = Label3.Caption & Chr(13) & " " & CStr(i + 1) & ": " & wds(i) & " " & wf(i)
End If
If i = 4 Then Exit For
Next i
End If
End Sub
麻烦懂的帮忙解释下...谢谢