新建一个工程,添加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