实现 窗体上的控件除了Command外, 只要回车就直接跳到下一个控件, 根据tabIndex值。
回车事件不影响一些控件的限制输入数字事件。
请问如何实现这个类

解决方案 »

  1.   

    写个方法,思路: sendkeys "{TAB}" .....
      

  2.   


    '类
    Option Explicit
    Private WithEvents myfrm As Form
    Public Sub Attach(frm As Form)
        Set myfrm = frm
        myfrm.KeyPreview = True
    End SubPrivate Sub myfrm_KeyUp(KeyCode As Integer, Shift As Integer)
        If KeyCode = 13 Then SendKeys "{Tab}"
    End Sub
    '窗体
    Option ExplicitPrivate myCLS As New clsPrivate Sub Form_Load()
        myCLS.Attach MeEnd Sub    Private Sub Form_Unload(Cancel As Integer)
        Set myCLS = Nothing
    End Sub Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
        Dim isNUM As Boolean
        If KeyCode = 13 Then Exit Sub
        isNUM = (KeyCode >= 65) And (KeyCode <= 90)
        '测试密码框的键盘输入是否是英文字母
        If isNUM = False Then
            Beep
            Text1.Text = ""
            '如果输入不是英文字母则响铃并且清空密码框内容
            MsgBox "非法字符输入!"
        End If
    End Sub