VB编程:获取字符串中数字个数-50_彭世瑜_新浪博客_算法

程序代码:

Private Sub Form_Click()

    Dim i As Integer, j As Integer

    j = 0                                  ‘ 计数

    Dim str As String

    str = "abcs123"

    For i = 1 To Len(str)

        If IsNumeric(Mid(str, i, 1)) Then    ‘判断是否为数字

            j = j + 1

        End If

    Next i

    Print j

End Sub