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

KeyPress within a web browser

P: 1
Hi there, i am currently trying to create a web browser within Visual Basic 6 but the problem i am having is that i want the program to execute a web address upon pressing the enter key (the web address would be in a text box)

I have got the web browser to execute a web address upon selecting it from a drop down list of favorites, this is the only way it will navigate the Internet for me.

Here is my code if that helps: -

Option Explicit

Dim KeyCode As Integer


Private Sub Command1_Click()
Favourites.RemoveItem 1
End Sub

Private Sub Command2_Click()
Dim Favourite_name As String
Open "F:\Favourite.txt" For Append As 1
Favourite_name = Text1.Text
Write #1, Favourite_name
Close #1
Favourites.Clear
Open "F:\Favourite.txt" For Input As 1
Do While Not EOF(1)
Input #1, Favourite_name
Form1.Favourites.AddItem Favourite_name
Loop
Close #1

End Sub

Private Sub Command3_Click()
WebBrowser1.GoBack
End Sub

Private Sub Command4_Click()
WebBrowser1.GoForward
End Sub

Private Sub Command5_Click()
WebBrowser1.Stop
End Sub

Private Sub Command6_Click()
WebBrowser1.GoHome
End Sub

Private Sub Favourites_Click()
Dim Clicked_item As String
Dim Number_index As String
Number_index = Favourites.ListIndex
Clicked_item = Favourites.List(Number_index)

WebBrowser1.Navigate Clicked_item

End Sub


Private Sub Form_Load()
Dim Favourite_name As String
WebBrowser1.Navigate "www.google.co.uk"
Open "F:\Favourite.txt" For Input As 1
Do While Not EOF(1)
Input #1, Favourite_name
Form1.Favourites.AddItem Favourite_name
Loop
Close #1

End Sub

Thanks
Jan 23 '08 #1
Share this Question
Share on Google+
2 Replies


kadghar
Expert 100+
P: 1,295
Hi there, i am currently trying to create a web browser within Visual Basic 6 but the problem i am having is that i want the program to execute a web address upon pressing the enter key (the web address would be in a text box)

I have got the web browser to execute a web address upon selecting it from a drop down list of favorites, this is the only way it will navigate the Internet for me.
(...)
Thanks
I think im not understanding you quite well, but do you want the application to do something when you press [Enter] in the textbox?

just add the code in the KeyDown Event of the Text_Box, under an IF, something like:

Expand|Select|Wrap|Line Numbers
  1. if keycode = 13 then 'im not sure, but i think 13 is the keycode for [enter]
  2.     '[write here the browsing code]
  3. end if
Jan 23 '08 #2

Expert 5K+
P: 8,434
Another way to trap Enter is to have a command button which is hidden behind something or off the display, with the Default property set to True.
Jan 24 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.