用
for i=1 to len(text1) 遍历字符串
各字母出现的次数的运算过程
Sub cisu(ByVal st, Suzu() As Integer)
st = UCase(st) '转换成大写
i = Asc(st) - 65
If i >= 0 And i <= 25 Then Suzu(i) = Suzu(i) + 1
End Sub
Private Sub Command1_Click()
Dim Suzu(25) As Integer '定义个数组,保存次数,0是A,25是Z
Cls
For i = 1 To Len(Text1)
st = Mid(Text1, i, 1)
cisu st, Suzu
Next
For i = 0 To 25
Print Chr(i + 65); ":"; Suzu(i)
Next
End Sub
Private Sub Command1_Click()
Dim S as string,A(1 to 3) as integer
S=Ucase(text1.text)
For i=1 to Len(S)
c=(Mid(S,i,1)
If C>="A" And C<="C" Then
A(Asc(C)-64)=A(Asc(C)-64)+1
End If
Next
For i=1 to 3
Print Chr(64+i) & "出现:" & A(i) & "次,出现频率:" & A(i)*100/Len(S) & "%"
Next
End Sub
添加按钮.text控件