Once you start it up, you should get a screen like this:
Choose "Standard EXE" and you should get a screen like this:
Here is when we must enable the internet features (For web browsing). Press the Shortcut "CTRL+T", and you will get this:
This is the component box, where you disable and enable components. If your box is empty, and shows no components, uncheck the "Selected Items Only" box. The components you are going to have to enable for a web browser are "Microsoft Internet Controls" and "Microsoft Internet Transfer Control 6.0". They should be right beside each other. Check mark both of them and click ok. Once you clicked ok, you should notice two (2) new buttons on your General Sidebar. They should look like this: (Yes, I used Paint. Shut up)
Ok, now that we have the internet part set up, we must make the Size correct. On the bottom right hand corner, you should see a little box, called "Form Layout". Move the little window around, and that is where it will start. Also, in the main window, select the bottom right corner of the "Form 1" box, and drag it to the correct size, then go to the "Form Layout" box again, and select where you want it to start-up.
Ok, when you have you size as you want it, click on the little globe in the general sidebar.
Now, with that tool selected, click a place on "Form1" where you want you web browser to start, and drag it to where you want it to stop. Once you’re done, click on the bottom right hand corner of the new white box, and drag it to perfection. The new white box should be called "WebBrowser1". To check, click on it (once) and look on the right side of your screen.
Congratulations! You have your browser!.....But no buttons.....
What were going to do now, is create a "Back", "Forward", "Home", and an address bar. It should be pretty easy. First, open up a space on your "Form1" box, so you have room to enter the buttons. (Make sure the WebBrowser1 isn’t taking up all of the space). First, lets create an address bar. Select the "Combo Box" button, and drag a text box on an open space (The right size for an address bar):
Name the new text box "Text1" in the properties section on the right hand of the screen (Like I showed you for WebBrowser1).
Now, right click on "Text1", and click "View Code". A blank text (Notepad Like) screen should come up. Click on the little arrow at the box that says "general", and select "Text1" or whatever you named your address bar ComboBox.
You should get some text like this:
Now, that is good. Very Good. *CLAP* *CLAP*. I’m proud. But oh noes! We don’t have a "Go" button! So, what were going to do, is one space under the
Quote:
Private Sub Text1_Change()
End Sub
End Sub
We are going to paste this code right here:
Quote:
Private Sub CommandButton1_Click()
WebBrowser1.Navigate Text1.Text
End Sub
WebBrowser1.Navigate Text1.Text
End Sub
It should now look like this, with a little separator in between:
I know what your thinking: "What? There is no CommandButton1". I know, I just did this to make it faster and easier. Now, get out of the "View Code" section by pressing the little "X" in the right hand corner. NO! Not the big "X", the small one. Now your screen should look like this again:
You need to add the "Go" button! Select the "CommandButton" in your General Sidebar, and go to "Form1" and create a button!(PS: I know my address bar is a textbox, not combobox, but you still need a combobox.)
Now you have your button! Click on the button (once), and go to the properties (Right Hand Side). You SHOULD notice the name is "CommandButton1". If not, change it to "CommandButton1". You might also notice when you look at the button, it doesn’t say go! So, look at the caption section in properties, and change it to "Go", or whatever you want your Go button to say.
Perfect! Now, test it out by pressing F5! Also, with the "Text1" bar, it might say "Text1" on it when you test it. To get rid of that, go to properties, and scroll to the bottom, and delete everything in the "Text" section (Which should only be "Text1")
Now, we will create a "Back", "Forward", "Stop", and "Home" button. To create those buttons, just do it the exact same way you did for the "Go" button, but don’t insert the code. Use this tool:
Ok, now it has the buttons. Change the Names to this:
BACK - cmdback
FORWARD - cmdforward
STOP - cmdstop
HOME - cmdHome
Now, right click on ONE of the buttons, and click view code. You will notice that their is no new code! Oh noes! Their is no new code! What do we do! We call Atl! That’s what! Sorry...His name just popped into my head....What we do, is paste this in the code section:
Quote:
Private Sub cmdBack_Click()
WebBrowser1.GoBack
End Sub
Private Sub cmdForward_Click()
WebBrowser1.GoForward
End Sub
Private Sub cmdStop_Click()
WebBrowser1.GoStop
End Sub
Private Sub cmdHome_Click()
WebBrowser1.GoHome
End Sub
Private Sub cmdBack_Click()
WebBrowser1.GoBack
End Sub
Private Sub cmdForward_Click()
WebBrowser1.GoForward
End Sub
Private Sub cmdStop_Click()
WebBrowser1.GoStop
End Sub
Private Sub cmdHome_Click()
WebBrowser1.GoHome
End Sub
Their. All the buttons work. Tada! j00 have a Web Browser!.....But wouldn’t it be much, much more simple to press the return key (enter) instead of pressing "Go!" everytime? Yesh!!!!!111!!1!! That’s why I made this:
Quote:
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
WebBrowser1.Navigate Text1.Text
End If
End Sub
If KeyCode = vbKeyReturn Then
WebBrowser1.Navigate Text1.Text
End If
End Sub
Place that at the end of your code! (Right-Click, View Code)
In the end, if you want your code to look like this:
Quote:
Private Sub cmdBack_Click()
WebBrowser1.GoBack
End Sub
Private Sub cmdForward_Click()
WebBrowser1.GoForward
End Sub
Private Sub cmdStop_Click()
WebBrowser1.Stop
End Sub
Private Sub cmdHome_Click()
WebBrowser1.GoHome
End Sub
Private Sub CommandButton1_Click()
WebBrowser1.Navigate Text1.Text
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
WebBrowser1.Navigate Text1.Text
End If
End Sub
WebBrowser1.GoBack
End Sub
Private Sub cmdForward_Click()
WebBrowser1.GoForward
End Sub
Private Sub cmdStop_Click()
WebBrowser1.Stop
End Sub
Private Sub cmdHome_Click()
WebBrowser1.GoHome
End Sub
Private Sub CommandButton1_Click()
WebBrowser1.Navigate Text1.Text
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
WebBrowser1.Navigate Text1.Text
End If
End Sub
Tada! Thanks for reading!
Now I will tell you an error, you might get if you use Internet Explorer 7.0.
That error will ONLY COME UP WHEN IN VISUAL BASIC. ONCE COMPILED TO AN EXE FILE (Enough with the caps), then it won’t come up. Also, you might get this error:
Well, to turn that off is a whole new thing. First, go into your control panel, or through internet Explorer, and click "Internet Options". You will get a screen like:
Now, change to the "Advanced" Tab, and look under the browsing section. Look at these three boxes, and make sure they are exactly like in the picture:
2 comments:
This may be the worst tutorial I have ever read
This tutorial isn't the worst, for me. Anyway, let's get to the point I filled the comment form, and submitted it. I've a code that avoids errors to share! You might find it handy, probably. In the click events, just add on the code with:
On Error GoTo ErrorHandler:
WebBrowser1.GoBack
ErrorHandler:
Exit Sub
Hopefully this helps!
Post a Comment