vb 利用文本框输入一个字符串,统计英文字母a,e,z出现次数,不区分大小写
1个回答
展开全部
Private Sub Command1_Click()
Dim a As Integer, e As Integer, z As Integer, c As String, i As Integer
For i = 1 To Len(Text1.Text)
c = LCase(Mid(Text1.Text, i, 1))
If c = "a" Then a = a + 1
If c = "e" Then e = e + 1
If c = "z" Then z = z + 1
Next
MsgBox "a次数" & a & vbCrLf & "e次数" & e & vbCrLf & "z次数" & z
End Sub
窗体上放一个文本框Text1,一个按钮Command1,在文本框中输入一个字符串,点击按钮即可获得统计结果。
追问
vbCrLf是啥
追答
回车换行符
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询