规定VB程序输入框只能输入数字
发布网友
发布时间:2023-02-14 17:49
我来回答
共2个回答
热心网友
时间:2023-10-05 02:39
Private Sub b_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Exit Sub '允许输入回车
If KeyAscii = 43 Then Exit Sub '允许输入+号
If KeyAscii = 45 Then Exit Sub '允许输入-号
If KeyAscii = 46 Then Exit Sub '允许输入小数点
If KeyAscii < 48 Or KeyAscii > 57 Then '屏蔽数字外的所有符号
KeyAscii = 0
End If
End Sub追问每个IF不用END吗?
热心网友
时间:2023-10-05 02:40
Private Sub b_KeyPress(KeyAscii As Integer)
If Not IsNumeric(b.Text) Then KeyAscii = 0
End Sub