VB编程:统计字符个数-52_彭世瑜_新浪博客

阅读 158

2022-04-02

VB编程:统计字符个数-52_彭世瑜_新浪博客_scala​​


程序源代码:

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

 

精彩评论(0)

0 0 举报