各位,我在登陆窗体中设置一个txtpassword(TextBox),当用户输入的密码与预先设置的密码一致,按下确定按钮进入下一个主界面,可是如果我想当用户输入之后按回车键也能实现密码是否正确的判断,该如何处理?

解决方案 »

  1.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbCrLf Then
    Call Command1_Click
    End If
    End Sub
      

  2.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
       If KeyAscii = 13  Then    'ascii=13时指按下了回车
           处理你的程序
       End If
    End Sub
      

  3.   

    Private Sub txtpassword_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = vbKeyReturn Then
            '验证按钮的Click事件
        End If
    End Sub
      

  4.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
       Call Command1_Click
    End If
    End Sub
    这样一定可以
      

  5.   

    也可以把command按纽的default属性设为true。