However, there is much to a browser than just the browser window. You need a List box to type in the address of other websites. And you need other navigational tools such as Back and Forward Buttons.
So do you want to know how to do it, or is that it?
Now then select the combo box icon from the toolbox, and draw a combo on the form. Add a label with the caption address and place it alongside the combo box. Then go to the code windows and type the following text:
Private Sub
Combo1_Click()
WebBrowser1.Navigate
Combo1.Text
End Sub
Private Sub
Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Combo1_Click
End If
End Sub
If you did that correctly you can now navigate anywhere on the web by typing the address of the site in the combo box. Now then you can add forward and back buttons to the browser to do exactly what it says on the tin!!
Add two command buttons on the form. Call them CmdBack and CmdForward respectively.
Change the two caption to Back and Forward. Double click on the back button. Add this code to the event CmdBack_Click….
WebBrowser1.GoBack
And then double click on the Forward button and add the code to the event CmdForward…
WebBrowser1.GoForward
This is roughly what you should end up with!!! A working Web Browser with Back and Forward Buttion and a address box to type away with!! If you find the browser windows too samll just make the form bigger and then extend the browser window is you see fit. Next Time, I will go into deeper mud, showing you how to load save and print, and add an about box as well. I will also show a pitfall which happens when you resize the form and you want to resize the browser window as well...
Comments