Make a Moderate Web-Browser


Yay for my 1st tutorial :)

Ok, so make your new form.

Now, go to components (Ctrl+T) and find "microsoft internet controls" Check it and click OK

now click the Earth Icon thingy, and make your Internet viewing part. Name it something simple, like "w"

Make a text box On top, for the Address, and 5 buttons also, (back, foward, home, stop, and refresh). then make a button next to the text-box and make the caption "go"

you might want at start the web browser to navigate to the home page or another page. type this code in:

VISUALBASIC Code
  1. Private Sub Form_Load()
  2. w.GoHome
  3. w.Silent = True
  4. End Sub
(if you want it to go to a webpage, instead of gohome, put navigate "https://yoursite.com")
the silent part makes it so your web browser shows no errors.


Now name the address bar something simple, like "T". and type this code in:
VISUALBASIC Code
  1. Private Sub T_Change()
  2. w.Navigate T.Text
  3. End Sub

Then, every time you type in a site in the address bar, it will go there. Now name the go button "Go". type this code in:
VISUALBASIC Code
  1. Private Sub Go_Click()
  2. w.Navigate T.Text
  3. End Sub


Now name the buttons back, forward, stop, refresh, and home.

put this code in:
VISUALBASIC Code
  1. Private Sub back_Click()
  2. On Error Resume Next
  3. w.GoBack
  4. End Sub
  5.  
  6. Private Sub forward_Click()
  7. On Error Resume Next
  8. w.GoForward
  9. End Sub
  10.  
  11. Private Sub home_Click()
  12. On Error Resume Next
  13. w.GoHome
  14. End Sub
  15.  
  16. Private Sub refresh_Click()
  17. On Error Resume Next
  18. w.refresh
  19. End Sub
  20.  
  21. Private Sub stop_Click()
  22. On Error Resume Next
  23. w.stop
  24. End Sub


Now you have all the buttons.
____________________________

Now maybe you want to have some advanced stuff?

Ok, make a menu now (right click > menu editor)
Make it like this:

File
....Save
....Print page
....Properties
....View Source
....Quit

name them A B C D E and F in consecutive order.

now type this code in:
VISUALBASIC Code
  1. Private Sub B_Click()
  2. w.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DODEFAULT
  3. End Sub
  4.  
  5. Private Sub C_Click()
  6. WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DODEFAULT
  7. End Sub
  8.  
  9. Private Sub D_Click()
  10. WebBrowser1.ExecWB OLECMDID_PROPERTIES, OLECMDEXECOPT_DODEFAULT
  11. End Sub
  12.  
  13. Private Sub F_Click()
  14. Unload Me
  15. End Sub
We will now make a new form for the view source part. go to Project > add form.

make a textbox on it and call it Source.

now add this code:
VISUALBASIC Code
  1. Private Sub E_Click()
  2. Form2.Visible = True
  3. Form2.Source = Form1.w.Document.documentElement.innerHTML
  4. End Sub
make sure form2 was previously hidden.


now to make the web browser resize when u change the window. find the difference betweeen your browser and window. this involves a little math :( (just subtract the height of the browser from the height of the form. I got 1890) make a timer called timer1. set the interval to something like 1-100. now add this code:
VISUALBASIC Code
  1. Private Sub Timer1_Timer()
  2. On Error Resume Next
  3. w.Width = Me.ScaleWidth
  4. w.Height = Me.ScaleHeight - 1890
  5. End Sub
make sure to replace 1890 with your number.


ok i may add more later, but now i have 2 go eat pizza :)

i will add the source code and the EXE to the downloads section ASAP
zar's Avatar
Author:
Views:
2,870
Rating:
Posted on Monday 31st December 2007 at 04:15 PM
zar
zar's Avatar
happened to me b4. reinstalling IE7 works for some people, you could also open "shdocvw.dll" instead.
Posted on Wednesday 26th December 2007 at 04:12 PM
Dalez
Dalez's Avatar
When i try to make it a Microsoft Internet Controls it just says 'File not found: c:windowssystem32ieframe.dll1' What do i do?
Posted on Monday 3rd December 2007 at 02:31 AM
ShadowMage
ShadowMage's Avatar
I'll post a dl of the random one i made O_o'
Posted on Sunday 2nd December 2007 at 02:40 AM
ShadowMage
ShadowMage's Avatar
Okay cool
Posted on Sunday 2nd December 2007 at 01:38 AM
zar
zar's Avatar
I am also only 1/2 way done. i will try and finish 2morrow.
Posted on Sunday 2nd December 2007 at 12:10 AM
ShadowMage
ShadowMage's Avatar
I use 2005 .net and 2008.net yet i love vb6 still for some stuff x] I've got a nice little web browser going in it been pondering on upgrading it to .net reliable and such but .net doesn't support sRet objects. -_-
Posted on Sunday 2nd December 2007 at 12:07 AM
MOD-Dan
MOD-Dan's Avatar
Yeh but a lot of people still code in VB6 as its very reliable and easy to code in. The newer updated versions are becoming more and more harder to learn and use XD
Posted on Sunday 2nd December 2007 at 12:05 AM
darklight19
darklight19's Avatar
You may want to switch from VB6 to VB9 or 10 I think it is.
Posted on Saturday 1st December 2007 at 10:35 PM
ShadowMage
ShadowMage's Avatar
Looks good =D
Posted on Saturday 1st December 2007 at 09:00 PM
zar
zar's Avatar
ppl like?