Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 And Len(Text1) >= 2 Then Text2.SetFocus End If End Sub
不要用Change事件,改用KeyUpPrivate Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) If Len(Text1) >= 2 Then Text2.SetFocus End Sub
Private Sub Text1_Change() If Len(Text1.Text) >= 2 Then Text2.SetFocus End SubPrivate Sub Text1_GotFocus() Text1.SelStart = 0 Text1.SelLength = Len(Text1) End Sub
排除退格键或者keycode在数字或字母范围内(判断条件你自己看吧),然后再setfocus,这样就可以修改了 Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) If KeyCode <> vbKeyBack And Len(Text1) >= 2 Then Text2.SetFocus End Sub
不要用Change事件,改用KeyUp Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) If Len(Text1) > = 2 Then Text2.SetFocus End Sub 可以的,你试试
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) If Len(Text1.Text) >= 2 Then Text2.SetFocus End SubPrivate Sub Text2_KeyUp(KeyCode As Integer, Shift As Integer) If Len(Text2.Text) = 0 And KeyCode = vbKeyBack Then Text1.SelStart = Len(Text1.Text): Text1.SetFocus End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) If Len(Text1.Text) > = 2 Then Text2.SetFocus End Sub Private Sub Text1_GotFocus() Text1.SelStart = 1 Text1.SelLength = 2 End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer) If Len(Text1.Text) > = 2 Then Text2.SetFocus End Sub Private Sub Text1_GotFocus() Text1.SelStart = 0 Text1.SelLength = 2 End Sub
If KeyAscii = 13 And Len(Text1) >= 2 Then
Text2.SetFocus
End If
End Sub
If Len(Text1) >= 2 Then Text2.SetFocus
End Sub
If Len(Text1.Text) >= 2 Then Text2.SetFocus
End SubPrivate Sub Text1_GotFocus()
Text1.SelStart = 0
Text1.SelLength = Len(Text1)
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode <> vbKeyBack And Len(Text1) >= 2 Then Text2.SetFocus
End Sub
If Len(Text1) > = 2 Then Text2.SetFocus
End Sub 可以的,你试试
If Len(Text1.Text) >= 2 Then Text2.SetFocus
End SubPrivate Sub Text2_KeyUp(KeyCode As Integer, Shift As Integer)
If Len(Text2.Text) = 0 And KeyCode = vbKeyBack Then Text1.SelStart = Len(Text1.Text): Text1.SetFocus
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If Len(Text1.Text) > = 2 Then Text2.SetFocus
End Sub Private Sub Text1_GotFocus()
Text1.SelStart = 1
Text1.SelLength = 2
End Sub
If Len(Text1.Text) > = 2 Then Text2.SetFocus
End Sub Private Sub Text1_GotFocus()
Text1.SelStart = 0
Text1.SelLength = 2
End Sub