'例: 在text1里输入abcddd , 就在picture里显示A = 1, B = 1, C = 1, D = 3#
'
'我已经写了以下的代码,但每次按command时就只统计我输入的第一个字母.
'错误范例: 输入abcddd , 就只显示A = 6
'不知那里错了,大家帮帮忙啊!!!!!!我已经想了很久了
Private Sub Command1_Click()
Dim a() As Long, c As String * 1
Dim i As Long, j As Long
ReDim a(1 To 26) As Long
For i = 1 To Len(Text1)
c = UCase(Mid(Text1, i, 1))
If c >= "A" And c <= "Z" Then
j = Asc(c) - Asc("A") + 1
a(j) = a(j) + 1
End If
Next
For i = 1 To 26
If a(i) > 0 Then Picture1.Print Space(3) & Chr(i + Asc("A") - 1) & "=" & a(i)
Next
End Sub
你错在mid函数了