Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
   Text2.SetFocus
End If
End Sub

解决方案 »

  1.   

    很容易..
    第一种:
    先设tabindex的值,然后用sendkeys{vbTab} '不太安全
    第二种:
    在TEXT1的keydown事件写:
      if keycode=vbkeyreturn then
          if text2.enabled=true and text2.visible=true then
               text2.setfoucs
          end if
      end if
    以此类推
      

  2.   

    再加一句
    在sendkeys "{Tab}"后面再加上一句,KeyAscii(或KeyCode)=0
    这一句比较关键,主要作用是去掉计算机发出的Beep声音
    完整语句是
    Private Sub Text1_KeyPress(KeyAscii As Integer)
        If KeyAscii = 13 Then
            SendKeys "{Tab}"
            KeyAscii = 0
        End If
    End Sub
      

  3.   

    试试API,SendKeys经常有问题,在98下还会将渐层显示的窗口颜色改为无渐层显示,SetFocus 则必须知道下一个控件的名称。(要执行下面的程序,请在窗体上加:两个TextBox控件,并将名称都命名成:Text1,也就是定义成数组)Option ExplicitPrivate Const VK_TAB = &H9
    Private Declare Sub keybd_event Lib "user32" _
        (ByVal bVk As Byte, ByVal bScan As Byte, _
        ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
       If KeyAscii = vbKeyReturn Then
          KeyAscii = 0
          keybd_event VK_TAB, 0, 0, 0
       End If
    End Sub
      

  4.   

    MoQi_123(老莫的春天) 的方法简单实惠!