VB:对输入的字符串统计每个英文字母(不区分大小写)出现的次数

如题,求解~~
2024-12-23 12:42:55
推荐回答(1个)
回答1:

新建一个工程,添加1个文本框(用来输入字符串),一个按钮;

Option Explicit

Private Sub Command1_Click()
Dim n As Integer
Dim MyStr As String
Dim i As Integer
MyStr = Text1.Text
n = 0
For i = 1 To Len(MyStr)
If Mid(MyStr, i, 1) >= "A" And Mid(MyStr, i, 1) <= "Z" Or Mid(MyStr, i, 1) >= "a" And Mid(MyStr, i, 1) <= "z" Then
n = n + 1
End If
Next i
Print n
End Sub