What is the keypress number for enter?
like left click is 2? Thanks
Printable View
What is the keypress number for enter?
like left click is 2? Thanks
It's "13".
If you want to know others then simply check this out.
VB Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, _ ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress MsgBox(Asc(e.KeyChar)) End Sub
oh ok thanks!
So if i wanted to make enter my button that sends the text to the main chat area it would look like:
VB Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, _ ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress) If KeyPress = "13" Then Label2.Text = "James:" & TextBox1.Text MsgBox(Asc(e.KeyChar)) End If End Sub
your code should looks like so :
VB Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object _ , ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If Asc(e.KeyChar) = 13 Then ' 'your code here ' End If End Sub
Thank You!