• (2 Pages)
  • +
  • 1
  • 2

Creating a Web Browser in VB.Net Rate Topic: ***** 2 Votes

#1 biggles2008  Icon User is offline

  • Bassface
  • member icon

Reputation: 9
  • View blog
  • Posts: 623
  • Joined: 05-March 08

Posted 07 March 2008 - 02:08 PM



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.)Posted 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.)Posted Image

*Docking it
*Posted Image


4) Personally i don't like the default color but that is not important but if you insist on changing the color...
Posted 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 >
Posted 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.)Posted 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

	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
Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
		WebBrowser1.GoBack()
	End Sub


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


Refresh Button
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
Posted Image




Here is the finished product running.

Posted 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


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: 7205

Is This A Good Question/Topic? 2
  • +

Replies To: Creating a Web Browser in VB.Net

#2 nitrr_student  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 23-March 08

Posted 25 March 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...
Was This Post Helpful? 0
  • +
  • -

#3 jagatworld  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 11-May 08

Posted 04 June 2008 - 05:23 AM

Thanks, its a cute tutorial, nice of you.

I have done this way back during vb5.0 and again now. :)
Was This Post Helpful? 0
  • +
  • -

#4 azertyuiop  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-May 08

Posted 07 June 2008 - 02:52 AM

View Postnitrr_student, on 25 Mar, 2008 - 05:47 AM, said:

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:

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


Was This Post Helpful? 0
  • +
  • -

#5 biggles2008  Icon User is offline

  • Bassface
  • member icon

Reputation: 9
  • View blog
  • Posts: 623
  • Joined: 05-March 08

Posted 21 June 2008 - 09:23 AM

Thankyou for all you comments and Thanks azertyuiop for answering his question.
Was This Post Helpful? 0
  • +
  • -

#6 narmer93  Icon User is offline

  • D.I.C Regular

Reputation: 8
  • View blog
  • Posts: 317
  • Joined: 13-March 08

Posted 05 July 2008 - 02:23 PM

well but the textbox doesn't change if the site is changed
how can we solve this problem?
Was This Post Helpful? 0
  • +
  • -

#7 mrmcpott  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 95
  • Joined: 24-November 08

Posted 29 December 2008 - 01:56 AM

View Postnarmer93, on 5 Jul, 2008 - 01:23 PM, said:

well but the textbox doesn't change if the site is changed
how can we solve this problem?


Double click the webbrowser control to access the code view for it. The webbrowser contorl has a method called "Document Completed." Under this method place the following code:

		TextBox1.Text = WebBrowser1.document.Url.AbsoluteUri



This will resolve your problem :)
Was This Post Helpful? 0
  • +
  • -

#8 Tamo0oha  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 03-April 09

Posted 03 April 2009 - 09:51 AM

:^:
Thanks a lot , really it's cute tutorial
Was This Post Helpful? 0
  • +
  • -

#9 MuSSi  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 84
  • Joined: 05-June 09

Posted 06 June 2009 - 03:51 AM

Where do you get your icons from I've been searching forever
Was This Post Helpful? 0
  • +
  • -

#10 socox  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-October 09

Posted 06 October 2009 - 05:57 AM

Hi,

I have problem with tabs...i create new tab but i cant open new page from my combobox in that new tab.

this is my code for new tab:
 Dim wb As New WebBrowser
		wb.Size = New Size(1286, 685)
		wb.Navigate(ComboBox1.Text)
		Dim tab As New TabPage("New Tab")
		tab.Controls.Add(wb)
		TabControl1.TabPages.Add(tab)
		TabControl1.SelectedTab = tab
		i = i + 1

Was This Post Helpful? 0
  • +
  • -

#11 Guest_makwana nilesh*


Reputation:

Posted 17 February 2010 - 12:29 AM

View PostMuSSi, on 06 June 2009 - 02:51 AM, said:

Where do you get your icons from I've been searching forever

how can i support css in browser
Was This Post Helpful? 0

#12 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,480
  • Joined: 29-May 08

Posted 17 February 2010 - 03:18 PM

It already does, the WebBrowser control is basically Internet Explorer.
Was This Post Helpful? 0
  • +
  • -

#13 Guest_Guest*


Reputation:

Posted 12 June 2010 - 06:21 AM

View PostMuSSi, on 06 June 2009 - 02:51 AM, said:

Where do you get your icons from I've been searching forever

Was This Post Helpful? 0

#14 raaif  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-March 10

Posted 12 June 2010 - 06:25 AM

View PostMuSSi, on 06 June 2009 - 02:51 AM, said:

Where do you get your icons from I've been searching forever

Well You can try "iconspedia.com" and "iconsarchive.com"
Was This Post Helpful? 0
  • +
  • -

#15 iont  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 23-July 10

Posted 23 July 2010 - 09:48 PM

i was thinkin if we could add a few stuff like a progressbar 2 show how much of the page has loaded, somethng like opera turbo, a confirmation to store passwords, themes & other cool stuff from other browsers. if anyone has the code for any of these please post it.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2