用KeyPress事件或Change事件
代码如下:
Private Sub Text1_Change()
if IsNumeric(text1.Text) then
if len(ltrim(text1.text))=5 then
text2.setfocus
end if
else
msgbox"你输入的不是数字!"
exit sub
end if
End Sub
或:
Private Sub text1_KeyPress(KeyAscii As Integer)
if IsNumeric(text1.Text) then
if len(ltrim(text1.text))=5 then
text2.setfocus
end if
else
msgbox"你输入的不是数字!"
exit sub
end if
End Sub