By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,900 Members | 1,078 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,900 IT Pros & Developers. It's quick & easy.

Check if user pressed Enter (Return)

P: n/a
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.
Nov 27 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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

"rpgfreak" <rp******@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
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.

Nov 27 '05 #2

P: n/a
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.
"rpgfreak" <rp******@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
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.

Nov 27 '05 #3

P: n/a
Yeah something like that, I used something else, it used the value of 851981,
but it worked
Nov 27 '05 #4

P: n/a
Right, I checked the code now, it was:

If e.KeyChar.GetHashCode = 851981 Then

'CODE HERE

endif
Nov 27 '05 #5

P: n/a
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

--
-iwdu15
Nov 27 '05 #6

P: n/a
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
rpgfreak wrote:
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.

Nov 30 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.