Monday, 26 December 2011

Visual Basic .net enter key on textbox


If you ever wanted to capture the key Enter on a text box, here is the code

Private Sub txtsearch_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtsearch.KeyPress
   If Asc(e.KeyChar) = 13 Then
   'Your code goes here...
   End If
End Sub
The best method i found is to create a sub process and call it from both of your codes. Both codes i mean the button that you press the Enter key and the button that you have to handle the user input

No comments:

Post a Comment

Reset numbering for Screenshots Win+PrtSc

I was using today the screen shot functionality of Windows 8.1 Win Key + PrtSc How to reset the numbering?