vb中怎么使文本框中必须输入的是数字,如果是字母或其他的话用信息框提示

文本框怎么设置只能输入a,b,c,d4个字母,
2024-12-18 20:37:00
推荐回答(1个)
回答1:

Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57
Case 97 To 100
Case Else
'If (KeyAscii < 48 Or KeyAscii > 57) Or (KeyAscii >= 97 Or KeyAscii <= 100) Then
'Else
KeyAscii = 0
MsgBox "输入了非法字符"
'End If
End Select
End Sub
已验证,运行正常