VB程序,输入一串字符,统计其中的各个英文字符的个数(不分大小写)?
答案:2 悬赏:70 手机版
解决时间 2021-12-19 06:58
- 提问者网友:你给我的爱
- 2021-12-18 06:02
输入的字符不分大小写,数字.
最佳答案
- 五星知识达人网友:孤独的牧羊人
- 2021-12-18 07:19
Private Sub Form_Click()
Dim char As String * 1, n%
Dim letter(1 To 26) As Integer
For i = 1 To Len(Text1)
char = LCase(Mid(Text1, i, 1))
If char >= "a" And char <= "z" Then
n = Asc(char) - Asc("a") + 1
letter(n) = letter(n) + 1
End If
Next i
For i = 1 To 26
If letter(i) <> 0 Then
Text1 = Text1 & "含有" & Chr(Asc("a") + i - 1) & "字母" & letter(i) & "个; "
End If
Next i
End Sub
'这是我写的代码,不明白的地方提出来哟!~ ^_^b
Dim char As String * 1, n%
Dim letter(1 To 26) As Integer
For i = 1 To Len(Text1)
char = LCase(Mid(Text1, i, 1))
If char >= "a" And char <= "z" Then
n = Asc(char) - Asc("a") + 1
letter(n) = letter(n) + 1
End If
Next i
For i = 1 To 26
If letter(i) <> 0 Then
Text1 = Text1 & "含有" & Chr(Asc("a") + i - 1) & "字母" & letter(i) & "个; "
End If
Next i
End Sub
'这是我写的代码,不明白的地方提出来哟!~ ^_^b
全部回答
- 1楼网友:独钓一江月
- 2021-12-18 07:56
private sub form_click()
dim char as string * 1, n%
dim letter(1 to 26) as integer
for i = 1 to len(text1)
char = lcase(mid(text1, i, 1))
if char >= "a" and char <= "z" then
n = asc(char) - asc("a") + 1
letter(n) = letter(n) + 1
end if
next i
for i = 1 to 26
if letter(i) <> 0 then
text1 = text1 & "含有" & chr(asc("a") + i - 1) & "字母" & letter(i) & "个; "
end if
next i
end sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯