Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
   Text2.SetFocus
End If
End Sub

解决方案 »

  1.   

    用keyDowm试试
    if KeyAscii=13 the Text2.setFocus
      

  2.   

    private sub text1_keypress(keyascii as integer)
    if keyascii=13 then
       sendkeys"{tab}"
    end ifend sub
      

  3.   

    设置断点,看看代码到底有没有被执行
    建议在KeyUp事件中使用,因为我有一次使用方向键控制时,按下方向键,keyPress事件并未被执行,真是怪事。
      

  4.   

    你的意思是一输入回车就进入下一个文本框吗,有控件数组吧很方便的,少写了很多代码。
    Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
    If KeyAscii = 13 Then
    Index = Index + 1
    Text1(Index).SetFocus
    End If
    End Sub
      

  5.   

    yan4911 (安安) :问题解决了吗?
      

  6.   

    shawls(小山(无业游民,VB版的众矢之的))的代码更少,最好就是用他啦,配合数姐就最好了