Private Sub Command1_Click()
Dim s As String
s = "1234567890asd"
MsgBox onlynum(s)
s = "0012345678901234"
MsgBox onlynum(s)
End Sub
Private Function onlynum(ByVal s As String) As Boolean
Dim i As Long
Dim olds As String
olds = s
For i = 0 To 9
olds = Replace(olds, CStr(i), "")
Next
Select Case Len(olds)
Case 0
onlynum = True
Case Else
onlynum = False
End Select
End Function
Private Sub Command1_Click()
If Val(Text1.Text) = Trim(Text1.Text) And InStr(Text1.Text, ".") = 0 Then
MsgBox "是数字", vbInformation
Else
MsgBox "非数字!", vbInformation
End If
End Sub