在keypress事件中 If IsNumeric(KeyAscii) = False Then KeyAscii = 0 End If 然后再 If x < 0 Or x > 13 Then Call MsgBox("输入出错", vbOKOnly) End If
Call MsgBox("输入出错", vbOKOnly) 不可取,那个人会加个call的。
在失去焦点的时候(例如在txtMonth中输入月份) if IsNumeric(txtMonth.text)=fale then MsgBox "请输入数字", vbOKOnly end if 然后在判断 if txtMonth.text<1 Or txtMonth>12 Then MsgBox "输入错误", vbOKOnly end if
If IsNumeric(KeyAscii) = False Then
KeyAscii = 0
End If
然后再
If x < 0 Or x > 13 Then
Call MsgBox("输入出错", vbOKOnly)
End If
if IsNumeric(txtMonth.text)=fale then
MsgBox "请输入数字", vbOKOnly
end if
然后在判断
if txtMonth.text<1 Or txtMonth>12 Then
MsgBox "输入错误", vbOKOnly
end if