Text1_keydown(keycode as ......
msgbox keycode
if keycode=13 then
 '这是个回车
elseif keycode=8 then
 '这是个....
endif
 '...
else
 keycode=0
end if你多试一试,就可以确定需要输入的数字的范围……输入的个数可以在Text的属性Max...里设置!

解决方案 »

  1.   

    首先将text的maxlength属性设为10
    另外,你可以text的LostFocus事件里进行判断其里面的内容是不是在字符和数字之间
    或者你是另个办法:调用VB里的microsoft masked edit control 6.0这个部件更方便!
      

  2.   

    首先将Text1的maxlength属性设为10然后:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If Not ((Chr(KeyAscii) Like "[0-9]") Or KeyAscii = 8) Then
            KeyAscii = 0
        End If
    End Sub