新建From1(窗体),新建Text1-5(TextBox),代码:
Private objText As TextBox
'键盘的 前后左右 可以控制到某个Text框,回车也可以 Text1_KeyPress无获得ASCII中不可见字符比如键盘左右键
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft: s_GoFront Text5
Case vbKeyRight: s_GoNext Text2
Case vbKeyReturn: s_GoNext Text2
End Select
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft: s_GoFront Text1
Case vbKeyRight: s_GoNext Text3
Case vbKeyReturn: s_GoNext Text3
End Select
End Sub
Private Sub Text3_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft: s_GoFront Text3
Case vbKeyRight: s_GoNext Text4
Case vbKeyReturn: s_GoNext Text4
End Select
End Sub
Private Sub Text4_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft: s_GoFront Text3
Case vbKeyRight: s_GoNext Text5
Case vbKeyReturn: s_GoNext Text5
End Select
End Sub
Private Sub Text5_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft: s_GoFront Text4
Case vbKeyRight: s_GoNext Text1
Case vbKeyReturn: s_GoNext Text1
End Select
End Sub
Private Sub s_GoFront(objText)
'向前跳,不能破坏数据
objText.SetFocus
End Sub
Private Sub s_GoNext(objText)
'向后前跳,全选数据
objText.SelStart = 0
objText.SelLength = Len(objText.Text)
objText.SetFocus
End Sub