vb的KeyAscii

Private Sub Text2_KeyPress(KeyAscii As Integer)
'禁止输入非数字字符
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End IfEnd Sub我想要如果KeyAscii=8时,不会被变成KeyAscii = 0,请问怎么办?

Private Sub Text2_KeyPress(KeyAscii As Integer)

If KeyAscii <> 8 And (KeyAscii < 48 Or KeyAscii > 57) Then KeyAscii = 0'为了逻辑明了 可以加个括号 End Sub
温馨提示:答案为网友推荐,仅供参考
相似回答