Welcome to Dream.In.Code
Become an Expert!

Join 136,930 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,831 people online right now. Registration is fast and FREE... Join Now!




Creating a Web Browser in VB.Net

 
Reply to this topicStart new topic

> Creating a Web Browser in VB.Net

Rating  5
biggles2008
Group Icon



post 7 Mar, 2008 - 01:08 PM
Post #1




This was the first thing I ever learned in VB i was completely honest i don't know why but if i learned it at the start anyone can do it. Ok lets get started.

1)File >new project>windows application (name it web browser or what ever)
1.)IPB Image


2) Make screen size to any size but big enough to see an entire web browser.

3) Add a Panel and dock it to the top (when clicked on the panel. Properties window on the right “Dock" )
3.)IPB Image

*Docking it
*IPB Image


4) Personally i don't like the default color but that is not important but if you insist on changing the color...
IPB Image




5)I have made many of these web browsers in the past just to keep it refreshed in my memory because if you do it right it can be a fun tool. So I created Back, Forward, Refresh and a GO! Button The attachment at the bottom of the page if you can’t be bothered making your own or you can just us Labels (basic text).

5) Add a text box and a buttons to the panel
5.) Here’s what i got so far >
IPB Image



6) I got the colors to change on the text box in the properties menu, thats not important i just did it for style.


7) Web browser. Just drag and drop it
7.)IPB Image


*ok don't rename anything ( you can change the text but NOT the name unless you change the coding) e.g. Say *originally it was " textbox1" and you rename it "Type here" you would have to put "Typehere.Text" understand? )

*double click the button so it opens the code window

CODE

    Private Sub PictureBox4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox4.Click
        
WebBrowser1.Navigate(TextBox1.Text)
    End Sub


Now I didn’t rename the picture boxes and i double clicked them to open in code window starting with Back>refresh>forward>go

Back Button
CODE
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
        WebBrowser1.GoBack()
    End Sub


Forward Button
CODE
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        WebBrowser1.GoForward()
    End Sub


Refresh Button
CODE
Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
        WebBrowser1.Refresh()
    End Sub


So you can just copy and past the code its that easy

Here’s what the finished web browser will look like in Debug mode

**You can also make a homepage easily by changing the URL value in the properties window just click the web browser we added earlier and the properties will change fo r that specific item
IPB Image




Here is the finished product running.

IPB Image



The buttons i made are in a .zip attachment

Understanding it

// Webbrowser1 is the name of the web browser item which we added when we were designing.
\\ Navigate is the command which tells the web browser to go to a specific web page as PictureBox4_Click (picture box 1 being my go button i designed and when you click it, it navigates to the web page


All the rest e.g. go back, go forward are straight forward


FULL CODE with comments


CODE

Public Class Form1




    Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
        WebBrowser1.GoBack()
    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        WebBrowser1.GoForward()
    End Sub


    Private Sub PictureBox3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox3.Click
        WebBrowser1.Refresh()
    End Sub


    Private Sub PictureBox4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox4.Click
        WebBrowser1.Navigate(TextBox1.Text)


    End Sub

End Class




Attached File  Buttons.zip ( 27.17k ) Number of downloads: 385
Go to the top of the page
+Quote Post


Register to Make This Ad Go Away!

nitrr_student
*



post 25 Mar, 2008 - 04:47 AM
Post #2
Hey how can we add event based operations on events such as pressing
keys such as "ctrl+enter" so that we can add "http://www."&textbox1.text& ".com"
and can make browsing more easy...
Go to the top of the page
+Quote Post

jagatworld
Group Icon



post 4 Jun, 2008 - 04:23 AM
Post #3
Thanks, its a cute tutorial, nice of you.

I have done this way back during vb5.0 and again now. smile.gif

Go to the top of the page
+Quote Post

azertyuiop
*



post 7 Jun, 2008 - 01:52 AM
Post #4
QUOTE(nitrr_student @ 25 Mar, 2008 - 05:47 AM) *

Hey how can we add event based operations on events such as pressing
keys such as "ctrl+enter" so that we can add "http://www."&textbox1.text& ".com"
and can make browsing more easy...


You can easily do this by going to your programming code, by double-clicking the object you're using to type the url in and then selecting the 'keydownevent', then you can type:


CODE

if e.keycode = keys.ctrl and e.keycode = keys.enter then
          (objectname).text = "www." & objectname.text & ".com"

Go to the top of the page
+Quote Post

biggles2008
Group Icon



post 21 Jun, 2008 - 08:23 AM
Post #5
Thankyou for all you comments and Thanks azertyuiop for answering his question.
Go to the top of the page
+Quote Post

narmer93
**



post 5 Jul, 2008 - 01:23 PM
Post #6
well but the textbox doesn't change if the site is changed
how can we solve this problem?
Go to the top of the page
+Quote Post


Fast ReplyReply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 12/3/08 10:36PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month