vb设计一个身份怔号码输入框

来源:百度知道 编辑:UC知道 时间:2024/05/15 12:12:19
vb设计一个身份怔号码输入框,并编写程序代码限制该输入框只能输入0-9的数码字符

自己添加一个text控件
Private Sub Form_Load()
Text1 = ""
Text1.MaxLength = 18
End Sub
Private Sub Text1_Change()
If Not IsNumeric(Text1.Text) Then MsgBox "警告!": Text1.Text = ""
End Sub

Private Sub Form_Load()
Text1 = ""
Text1.MaxLength = 18
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub