Check if user pressed Enter (Return)

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a textbox where u have to input an URL and when u press on a "GO"
button, my browser window navigates to the URL, but if the textbox is in
focus and I finish typing the URL, and then press Enter, I want to the
browser to navigate too.
How can I do this? I think it has something to do with e.keypress or
something but I'm not sure...
Please help me.
 
I am trying to do something similar. Follow my posts yesterday (Why Doesn't
13 Equals 13?) and my post today (Problem With GetNextControl).

Bob
 
Use the KeyPress event for the text box. Then I think you do something
like:

if e.keypress=chr(13) then GoNavigate

or maybe it's e.keychar. I don't know. I don't have VS open right now to
check.
 
Yeah something like that, I used something else, it used the value of 851981,
but it worked
 
Right, I checked the code now, it was:

If e.KeyChar.GetHashCode = 851981 Then

'CODE HERE

endif
 
you could also do it in the keydown event, so theres no memorizing key numbers

if e.keycode = keys.enter then

''do stuff here

end if
 
then i used combobox keypress event instead of textbox
example:
Private Sub cboAddress_KeyPress(ByVal sender As System.Object, ByVal e
As System.Windows.Forms.KeyPressEventArgs) Handles cboAddress.KeyPress
If Asc(e.KeyChar) = Keys.Enter Then
Dim bFound As Boolean
bFound = False
For i As Integer = 0 To cboAddress.Items.Count - 1
If cboAddress.Items(i) = "http://" & cboAddress.Text Then
bFound = True
Exit For
End If
Next
If bFound = False Then
cboAddress.Text = "http://" & cboAddress.Text.ToString
End If
AxWebBrowser1.Navigate(cboAddress.Text)
End If
End Sub

regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top