I made a password field and when i type my password, i want to easily press my Enter button and it presses a command button for me on the form.
How would i make it do this? When i press my Enter/Return button, a command button gets pressed
Printable View
I made a password field and when i type my password, i want to easily press my Enter button and it presses a command button for me on the form.
How would i make it do this? When i press my Enter/Return button, a command button gets pressed
what about
VB Code:
Private Sub txtinformation_KeyPress(KeyAscii As Integer) If KeyAscii = vbKeyReturn Then cmdenter_Click End If Exit Sub End Sub
Thanks
Or set the default property of a Command button to True. This will make the command button pressed when ever you press the Enter button.
And you can do same with the ESC key by setting the Cancel property of a command button to true
ah cool thanks for the quick reply
two methods, ill try both!
Thanks, cya
Instead of keypress you can have the keydown event. It is almost the same thing. :
VB Code:
Private Sub txtinformation_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyReturn Then cmdenter_Click End If Exit Sub End Sub