展开全部
新建一个工程,添加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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询