如要对某一控件作控制,有没有简单点的代码如:
当用户完成第一个输入框的输入后,总爱习惯性的加一个回车,希望输入焦点落到下一个输入框中(DOS中大多数应用程序是如此)只需在输入框的KeyPress事件中加入如下代码: IF KeyASCII=13 Then KeyASCII=0 Sendkeys "{TAB}" END IF 那我是不是每一个输入框都去加这段代码?有没有简单一点,不用每一个输入框都去加这代码的方法?

解决方案 »

  1.   

    把form的keypreview设置为truePrivate Sub Form_KeyPress(KeyAscii As Integer)
        If KeyAscii = 13 Then
            KeyAscii = 0
            SendKeys "{TAB}"
        End If
    End Sub
      

  2.   

    谢谢,再请问:Private Sub Text1_GotFocus()
    DoEvents
    Text1.BorderStyle = 1
    End SubPrivate Sub Text1_LostFocus()
    Text1.BorderStyle = 0
    End SubPrivate Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    DoEvents
    Text1.BorderStyle = 1
    End Sub这个又该如何写?