VB的Text中能输入数字,但要退格键能用.
数字到能输入,但我想删除数字就不行了PrivateSubText11_KeyPress(KeyAsciiAsInteger)IfKeyAscii<48OrKeyAscii...
数字到能输入,但我想删除数字就不行了
Private Sub Text11_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub
这个想用退格键删除不行
怎样启用退格啊
给小弟代码 展开
Private Sub Text11_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub
这个想用退格键删除不行
怎样启用退格啊
给小弟代码 展开
4个回答
展开全部
这样吧:
Private Sub Text11_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then
ElseIf KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End If
End Sub
下面的也行:
Option Explicit
Private Sub Text11_KeyPress(KeyAscii As Integer)
KeyAscii = IIf((KeyAscii = 8 Or (KeyAscii >= 48 And KeyAscii <= 57)), KeyAscii, 0)
End Sub
Private Sub Text11_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then
ElseIf KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End If
End Sub
下面的也行:
Option Explicit
Private Sub Text11_KeyPress(KeyAscii As Integer)
KeyAscii = IIf((KeyAscii = 8 Or (KeyAscii >= 48 And KeyAscii <= 57)), KeyAscii, 0)
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Text11_KeyPress(KeyAscii As Integer)
If (KeyAscii < 48 Or KeyAscii > 57) and KeyAscii<>8 Then KeyAscii = 0
End Sub
If (KeyAscii < 48 Or KeyAscii > 57) and KeyAscii<>8 Then KeyAscii = 0
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Text11_KeyPress(KeyAscii As Integer)
If KeyAscii <> vbKeyBack And KeyAscii < 48 Or KeyAscii <> vbKeyBack And KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
If KeyAscii <> vbKeyBack And KeyAscii < 48 Or KeyAscii <> vbKeyBack And KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询