一个小例子:
Private Sub Text1_KeyPress(KeyAscii As Integer)
'在名称文本框中按回车键时,焦点移到密码框
If KeyAscii = 13 Then
Text2.SetFocus 'text2获得焦点
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
'在密码文本框中按回车键时,单击命令按钮
If KeyAscii = 13 Then
Command1.click
End If
End Sub