怎样让vb的textbox只能输入正整数
3个回答
展开全部
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 Then
Dim re
Set re = CreateObject("VBScript.RegExp")
re.IgnoreCase = True
re.Global = True
re.Pattern = "^([1-9](\d+)?)?$"
If Not re.test(Text1.Text & Chr(KeyAscii)) Then
KeyAscii = 0
End If
End If
End Sub
If KeyAscii <> 8 Then
Dim re
Set re = CreateObject("VBScript.RegExp")
re.IgnoreCase = True
re.Global = True
re.Pattern = "^([1-9](\d+)?)?$"
If Not re.test(Text1.Text & Chr(KeyAscii)) Then
KeyAscii = 0
End If
End If
End Sub
展开全部
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 And (KeyAscii > Asc("9") Or KeyAscii < Asc("0")) Then KeyAscii = 0
End Sub
If KeyAscii <> 8 And (KeyAscii > Asc("9") Or KeyAscii < Asc("0")) Then KeyAscii = 0
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
isnumeric和ABS函数共同使用。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询