怎么让vb2008的TextBox控件只能输入正整数??
展开全部
可以使用正则表达式,比较方便。
追问
具体怎么操作呢?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Option Explicit
Private Sub Text1_Change()
Dim i As Integer, a As Integer
Dim c As String
Dim s As String
For i = 1 To Len(Text1)
c = Mid(Text1, i, 1)
a = Asc(c)
If a >= 97 And a <= 122 Then
s = s & c
ElseIf a >= 48 And a <= 57 Then
s = s & c
ElseIf a >= 65 And a <= 90 Then
s = s & c
End If
Next i
Text1 = s
End Sub
Private Sub Text1_Change()
Dim i As Integer, a As Integer
Dim c As String
Dim s As String
For i = 1 To Len(Text1)
c = Mid(Text1, i, 1)
a = Asc(c)
If a >= 97 And a <= 122 Then
s = s & c
ElseIf a >= 48 And a <= 57 Then
s = s & c
ElseIf a >= 65 And a <= 90 Then
s = s & c
End If
Next i
Text1 = s
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询