有两个TEXT,一个CMD按钮,用代码实现了按回车键光标由TEXT1移动TEXT2,再回车移动到CMD,再回车就执行CMD按下,然后就是我要问的问题,在CMD上执行按下之后同时光标再回到TEXT1要怎么实现?

解决方案 »

  1.   

    VB的CommandButton好像不能接受键盘事件
    你在Click事件中写算了
      

  2.   

    加一行代碼就能了
    Private Sub Command1_Click()
        Text1.SetFocus
    End Sub
      

  3.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    Text2.SetFocus
    End If
    End SubPrivate Sub Text2_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
    Command1.SetFocus
    End If
    End SubPrivate Sub Command1_Click()
    '处理你的事件
    Text1.SetFocus
    End Sub