How can I disable the "Enter" key in a
multi-line text box?
Thanks.
Printable View
How can I disable the "Enter" key in a
multi-line text box?
Thanks.
Code:Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then KeyCode = 0
End Sub
The KeyDown event is not working with
the "Enter" key!!!
Any suggestions?
Thanks
[Edited by VBonliner on 10-16-2000 at 03:58 AM]
Problem with KeyDown event and the "Enter" Key.
Use the KeyPress event.
Code:Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then KeyAscii = 0
End Sub
Thanks Matthew. It worked.
[Edited by VBonliner on 10-16-2000 at 08:25 AM]
Likewise, Kedaman's method of using 13 (as opposed to vbKeyReturn) would work as well.
...the difference being kedaman's code calls the default sound while Matthew's code doesn't.
The code that kedaman gave for KeyCode did not seem to work.
But 13 and vbKeyReturn are the same thing.
So this:
would be the same as this:Code:Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then KeyAscii = 0
End Sub
But it does not work in the KeyCode event.Code:Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then KeyAscii = 0
End Sub
Just a little mistake by kedaman, we aren't all perfect :rolleyes:. I make mistakes all the time, do I care? A little, but oh well, this is vb-world, a little edit/delete post can change everything ;).