Private Sub text1_KeyPress(KeyAscii As Integer)
If ((KeyAscii < 48 Or KeyAscii > 57) And KeyAscii <> 8 And KeyAscii <> 9) Then
KeyAscii = 0
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case Asc("-") '不允许负数
KeyAscii = 0
Case 8 '无变化,退格键不屏蔽
Case Asc(" ") '不允许空格
KeyAscii = 0
Case Asc(".") '46 '不允许小数点
KeyAscii = 0
Case Is < Asc(0) '48
If KeyAscii <> vbKeyReturn Then KeyAscii = 0
Case Is > Asc(9) '57
KeyAscii = 0
End Select