我建立一个text的框,想实现只能输入0-9,而且第一个不能是0 Dim a As Boolean
a = Chr(KeyAscii) Like "[0-9]" Or KeyAscii = 8
If a = False Then
KeyAscii = 0
Else
If Mid(Text2.Text, 1, 1) = 0 Then
MsgBox "不能为0"
Text2.Text = ""
Text2.Refresh
End If
End If我用了这段代码,但是不理想,怎么才能直接让第一个不能输入0?就好象前面不能输入ABCD一样,高手们指点下小弟:)
a = Chr(KeyAscii) Like "[0-9]" Or KeyAscii = 8
If a = False Then
KeyAscii = 0
Else
If Mid(Text2.Text, 1, 1) = 0 Then
MsgBox "不能为0"
Text2.Text = ""
Text2.Refresh
End If
End If我用了这段代码,但是不理想,怎么才能直接让第一个不能输入0?就好象前面不能输入ABCD一样,高手们指点下小弟:)
If KeyAscii < 49 Or KeyAscii > 57 Then
KeyAscii = 0
Exit Sub
End If
Else
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
Exit Sub
End If
End If