How To Create A Web Browser In Visual Basic 6.0
#1
Reputation: 93
- Posts: 5,561
- Joined: 20-February 09
Posted 24 March 2009 - 12:23 AM
I will show you how to create a simple web browser in VB6. This web browser is very self explanatory but the steps are shown. Once loaded Visual Basic, follow these steps.
1.Create a new project, and then go to "Project" on the menu.
Click components or use the shortcut Ctrl+T
2.Find the component "Microsoft Internet Controls," check it and click "Apply" and then "Close."
3.Click the icon that was just added in the tools window, and draw a large sized window with it but big enough to add in a few buttons and textboxes. This is going to be where you view web pages through your browser.
4.Make a text box; this will be your URL bar where you type in the address of the website you want to see. (You may also create a heading or such)
5.Make four command buttons, these are going to be your Go, Back, Forward, and Refresh buttons, change the captions accordingly, and name each of them Cmdgo, Cmdback, CmdForward, and CmdRefresh. Place them in appropriate positions and now we code.
Firstly we will code the back button.
Private Sub cmdback_Click() WebBrowser1.GoBack End Sub
Then we will code the Forward button which has a similar code to the back button.
Private Sub Cmdforward_Click() WebBrowser1.GoForward End Sub
Now we give the code to the Go button. This will link to the text box as when we click the button, the URL within the text box will open up.
Private Sub cmdgo_Click() WebBrowser1.Navigate (Text1.Text) End Sub
This will refresh the page and reload it.
Private Sub cmdrefresh_Click() WebBrowser1.Refresh End Sub
Double click the form and type the WebBrowser part in. This is for the homepage (Google is my default)
Private Sub Form_Load() WebBrowser1.Navigate ("http://google.com") End Sub
This changes the text box's text into what URL that you're currently at, and the next line makes the caption of your form into the header of the URL.
Private Sub WebBrowser1_StatusTextChange(ByVal Text As String) Text1.Text = (WebBrowser1.LocationURL) Form1.Caption = (WebBrowser1.LocationName) End Sub
So now it should look like (or similar) like image attached.
Attached image(s)
Is This A Good Question/Topic? 3
#2 _VB125
-
- New D.I.C Head
Reputation: 0
- Posts: 2
- Joined: 18-July 09
Posted 01 October 2009 - 04:39 AM
what about an advanced web browser or something of the sort?
#3 firebolt
Reputation: 93
- Posts: 5,561
- Joined: 20-February 09
Posted 01 October 2009 - 05:13 AM
That was definitely an option, however, Microsoft will end support to VB6 so that would mean most of these VB6 tutorials will serve a little part of this community, and so the main focus will be at VB.NET and future versions.
#4 ShadowM82
-
- New D.I.C Head
Reputation: 0
- Posts: 1
- Joined: 24-January 10
Posted 24 January 2010 - 01:09 AM
Hey guys. Well im really excited to try this out but whenever i try to apply the Microsoft Internet Controls component, the program tells me error in accessing. any ideas on how to fix this??
#5 darkvai
-
- New D.I.C Head
Reputation: 1
- Posts: 7
- Joined: 23-March 10
Posted 25 March 2010 - 02:42 AM
awesome tut.
did you make a browser?
#6 raziel_
Reputation: 470
- Posts: 4,281
- Joined: 25-March 09
Posted 25 March 2010 - 12:47 PM
in this tut he just did
but you can try and make advanced if you want. but like firebolt say microsoft will drop the support of vb6 sooner or latter
This post has been edited by NoBrain: 25 March 2010 - 12:47 PM
#7 Guest_petnjau*
Posted 27 July 2010 - 06:09 AM
NoBrain, on 25 March 2010 - 11:47 AM, said:
in this tut he just did
but you can try and make advanced if you want. but like firebolt say microsoft will drop the support of vb6 sooner or latter
wow its a nice one; thanks alot for this codes
Was This Post Helpful? 0
#8 Guest_saga*
Posted 07 February 2011 - 11:17 AM
I reffered your browser code, but im getting ERROR :
Runtime error "424" :object required
okz hel me out..
Was This Post Helpful? 0
#9 BobRodes
Reputation: 607
- Posts: 3,086
- Joined: 19-May 09
Posted 18 March 2011 - 02:47 PM
If you don't think that web browser is advanced enough, you can always add complexity to it. Otherwise, you can do this. Go to References this time (NOT Components as you have here) and set a reference to "Microsoft Internet Controls." Then add a module to your project and put this:
Sub Main() Dim ie As InternetExplorer Set ie = New InternetExplorer ie.Navigate2 "http://www.google.com" ie.Visible = True End Sub
Of course, you don't have the same control, because all you're really doing is sending messages to an instance of iexplore.exe from your program, and anyone can use the instance directly as well as from your program (unless you commit a few sins to prevent that). So, please understand that I'm not recommending this as a full-on alternative to firebolt's post; it isn't. I'm just mentioning that there's another tool in the box.
#10 Rhymer
-
- D.I.C Regular
Reputation: 23
- Posts: 282
- Joined: 21-April 09
Posted 28 March 2011 - 01:55 PM
Is the Microsoft Internet Control an earlier version of IE say version 6?
Will this control prevent or allow pop-ups?
Are there settings to disable options like graphics?
#12 charifexx
-
- New D.I.C Head
Reputation: 0
- Posts: 12
- Joined: 13-February 15
Posted 08 June 2015 - 11:21 PM
Thanks for the tutorial
But this error shows when I load a certain url
#13 modi123_1
Reputation: 16451
- Posts: 65,238
- Joined: 12-June 08
Posted 09 June 2015 - 06:47 AM
@charifexx - what errors? It may be a good idea to copy/paste your errors and your current code in a new VB6 forum post.
#14 charifexx
-
- New D.I.C Head
Reputation: 0
- Posts: 12
- Joined: 13-February 15
Posted 14 June 2015 - 10:13 PM
@modi123_1 hi! Actually I don't really understand what I'm doing. I want to load this page but it actually looked messed up.
Here are my codes:
Private Sub Command1_Click()
WebBrowser1.GoBack
End Sub
Private Sub Command2_Click()
WebBrowser1.GoForward
End Sub
Private Sub Command3_Click()
WebBrowser1.Navigate2 (Text1.Text)
End Sub
Private Sub Command4_Click()
WebBrowser1.Refresh
End Sub
Private Sub Command5_Click()
WebBrowser1.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DODEFAULT
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate2 "http://www.zillow.com/homedetails/15607-Lago-Villa-Dr-Tomball-TX-77377/28369446_zpid/"
WebBrowser1.Silent = True
End Sub
Private Sub WebBrowser1_StatusTextChange(ByVal Text As String)
Text1.Text = (WebBrowser1.LocationURL)
Form1.Caption = (WebBrowser1.LocationName)
End Sub
How To Create A Web Browser In Visual Basic 6.0
Source: https://www.dreamincode.net/forums/topic/94968-create-a-simple-web-browser/
Posted by: wardsleve2000.blogspot.com
0 Response to "How To Create A Web Browser In Visual Basic 6.0"
Post a Comment