m=4 if isnumeric(m) then msgbox "数字" else msgbox "非数字" end if
忘记问了,我首先要从text1.text中读取才可以,这样要如何判断呢?真是辛苦大家了
m=text1.text if isnumeric(m) then msgbox "数字" else msgbox "非数字" end if…………………………
顶也可以使用Val来判断: Option ExplicitPrivate Sub Command1_Click() Dim varP As Variant varP = "df11" If Val(varP) Then Debug.Print "数字" Else Debug.Print "非数字" End If End Sub
if isnumberic(m) = false then 非数字 end ifVariant 类型
Private Sub Command1_Click() S = Text1.Text l = Len(S) Pattern = String(l, "#") If S Like Pattern Then MsgBox "数字" Text1.SetFocus Else MsgBox "不是数字" End If End Sub
xxx.setfocus
比如m=4;
判断m是否是数字
是数字
else
不是数字
endif
if isnumeric(m) then
msgbox "数字"
else
msgbox "非数字"
end if
if isnumeric(m) then
msgbox "数字"
else
msgbox "非数字"
end if…………………………
Option ExplicitPrivate Sub Command1_Click()
Dim varP As Variant
varP = "df11"
If Val(varP) Then
Debug.Print "数字"
Else
Debug.Print "非数字"
End If
End Sub
就是如果我只在非数字的时候,才用,isnotnumeric(m)好像没有,类似的应该是哪个函数啊?
还有一个问题就是,这里的m没有声明,它算是什么类型的啊?
非数字
end ifVariant 类型
S = Text1.Text
l = Len(S)
Pattern = String(l, "#")
If S Like Pattern Then
MsgBox "数字"
Text1.SetFocus
Else
MsgBox "不是数字"
End If
End Sub
VB不用分号作为语句分割的。
也不用 // 作为注释。