vb中如何用一个textbox只允许英文字母和数字输入
1个回答
展开全部
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询