VB编程:统计字符个数-52
原创
©著作权归作者所有:来自51CTO博客作者彭世瑜的原创作品,请联系作者获取转载授权,否则将追究法律责任
程序源代码:
Private Sub Command1_Click()
'*****************清空************
Label4.Caption = ""
Label6.Caption = ""
Label8.Caption = ""
Label10.Caption = ""
'*****************统计************
Label2.Caption = Len(Text1)
Dim mystr As String
For i = 1 To Len(Text1)
mystr = Mid(Text1, i, 1)
Select Case mystr
Case "a" To "z", "A" To "Z"
Label4.Caption = Val(Label4.Caption) + 1
Case " "
Label6.Caption = Val(Label6.Caption) + 1
Case 0 To 9
Label8.Caption = Val(Label8.Caption) + 1
Case Else
Label10.Caption = Val(Label10.Caption) + 1
End Select
Next i
End Sub
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章