读书人

vb6.0里面怎么限定不能输入*/.等记号

发布时间: 2012-02-17 17:50:42 作者: rapoo

vb6.0里面如何限定不能输入*/.等记号, 但是可以输入英文字符呢
vb6.0里面如何限定不能输入*/.等记号, 但是可以输入英文字符呢

[解决办法]

Private Sub Form_Load()
Check1.Caption = "英文 "
Check2.Caption = "数字 "
Check1.Value = 1
Check2.Value = 1
Text1.Text = " "
flg = True
End Sub

Private Sub Text1_Change()
If Not flg And Len(Text1.Text) > = 1 Then
Text1.Text = Replace(Text1.Text, Chr(k_code), " ")
flg = True
k_code = " "
Text1.SelStart = Len(Text1.Text)
End If
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 48 To 57
If Check2.Value <> 1 Then MsgBox "不能输入数字 ": flg = False: k_code = KeyAscii
Case 65 To 90, 97 To 122
If Check1.Value <> 1 Then MsgBox "不能输入英文 ": flg = False: k_code = KeyAscii
Case Else
MsgBox "非法字符! ": flg = False: k_code = KeyAscii
End Select
End Sub

读书人网 >VB

热点推荐