Hack Forums
[.NET] [TUT] How to make a simple WebBrowser in VB 2010! [TUT] - [ Pictures] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] [TUT] How to make a simple WebBrowser in VB 2010! [TUT] - [ Pictures] (/showthread.php?tid=2516289)

Pages: Pages 1 2


[TUT] How to make a simple WebBrowser in VB 2010! [TUT] - [ Pictures] - WarrioR™ - May 21, 2012

Hey Hack Forums,

I have decided to make a new tutorial for new members to learn how to code, this is my tutorial on how to make a web browser. This tutorial was created by me a VERY long time ago but it still works and it is effective. Here it is:

Required items in order to successfully follow this tutorial:

Visual Studio/basic 2010
Some coding skills
A brain
Able to understand and read English!


Firstly, you must open Visual Basic 2010 and then click new project and choose the windows form application as explained in the following picture:

Spoiler (WARNING: Potential SPAM or INFECTED LINK)

Secondly, you can change the name of the browser and the size by doing the following:

Spoiler (WARNING: Potential SPAM or INFECTED LINK)

Thirdly, you must add a panel by simply clicking the toolbox in the top left corner and do the following:

Spoiler (WARNING: Potential SPAM or INFECTED LINK)

Fourthly, you must go to toolbox (once again) and choose WebBrowser and do the following:

Spoiler (WARNING: Potential SPAM or INFECTED LINK)

Fifthly, you must open toolbox and add buttons (five of them in fact) and do the following with them:

Spoiler (WARNING: Potential SPAM or INFECTED LINK)

Sixthly, you must re-name the buttons into what I have done in the following picture:

Spoiler (WARNING: Potential SPAM or INFECTED LINK)

Seventhly, you must add a textbox and extend it as I have done. You must also add a label, all of the required objects in this step are in the toolbox.

Spoiler (WARNING: Potential SPAM or INFECTED LINK)

Eighthly, you must add a statusstrip at the bottom of the webbrowser as I have done, you can obtain the status bar from the toolbar.

Spoiler (WARNING: Potential SPAM or INFECTED LINK)

Tenthly, it is finally time to get some coding done!, double click the buttons before you add the codes, he codes for the buttons are below:

Back Button:
Code:
WebBrowser1.GoBack()
Quote:Forward Button:
Code:
WebBrowser1.GoForward()

Refresh Button:
Code:
WebBrowser1.Refresh()

Stop Button:
Code:
WebBrowser1.Stop()

Go Button:
Code:
WebBrowser1.Navigate(Textbox1.Text)

The progress bar:
Code:
Private Sub WebBrowser1_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
Dim p, d, t As Integer
d = e.CurrentProgress
t = e.MaximumProgress
If t < 1 Then t = 1
p = Int(d / t) 100
If p > 100 Or p < 0 Then Exit Sub
ToolStripProgressBar1.Value = p
End Sub


After you have added the codes for the buttons you are done!, the codes should be something like this:

[Image: hi6ue.png]
This is the whole code:

Quote:Public Class Form1

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

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

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
WebBrowser1.Stop()
End Sub

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

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

Private Sub WebBrowser1_ProgressChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
Dim p, d, t As Integer
d = e.CurrentProgress
t = e.MaximumProgress
If t < 1 Then t = 1
p = Int(d / t)
100
If p > 100 Or p < 0 Then Exit Sub
ToolStripProgressBar1.Value = p
End Sub
End Class

Finally, after you have done everything and added all the codes etc, you can change the icon of the browser and the name of the things.

This is how it looks like:

[Image: vXYVL.png]

If you have any questions, feel free to post in this thread or private message me!

Thank you and enjoy!


* - Wizart - May 21, 2012

Very nice tutorial, helped me learn to make a browser.


Although, it might help to resize the pictures a little bit...


* - Tech Experts - May 21, 2012

hahahaha i made this browser before 5 month ..! btw nice effort i liked that work really :) :D thanks !


* - Aul0s - May 21, 2012

Thanks a lot, i will try this later.


* - Decim - May 21, 2012

This is actually supposed to be in the Visual Basic and .NET Framework [coding] section.
Nevertheless, it's a nice tutorial.


* - Xylon - May 21, 2012

Use the chrome engine or firefox engine it's much better :P Hate IE..


* - Advanced - May 21, 2012

You should add spoilers for the pictures. Anyways, nice tutorial. 👍


* - Aul0s - May 22, 2012

Thanks mate ! I'm beginning VB and it will help me a lot.


* - i3D - May 22, 2012

Nice tutorial bro, Thanks!

~i3D 🤝


* - Lambasoft - May 22, 2012

I was like: Orange spoilers ! HOOW ! CLick .... Ohh i see what you did there =|

Thanks for the share though OP ^^


* - SomeWhiteGuy - May 22, 2012

Embed the pictures, it's annoying to be redirected to them.


* - LittleBrotherTrucker - May 22, 2012

Worked pretty good. Now I just need to figure out how how to make it javascript compatible.

By the way, with a little customization it actually looks pretty decent.

http://screensnapr.com/v/cn9Y2R.png

(Complete with mismatched buttons lol)


* - SomeWhiteGuy - May 22, 2012

You should also add a check under GoBack to see if it CanGoBack and the same with GoForward. You could also add under WebBrowser1.DocumentCompleted TextBox1.Text = WebBrowser1.Uri.ToString() so it would be the absolute URI and not a relative one. It looks better.


* - WarrioR™ - May 22, 2012

(May 22, 2012 05:06 PM)LittleBrotherTrucker Wrote:  Worked pretty good. Now I just need to figure out how how to make it javascript compatible.

By the way, with a little customization it actually looks pretty decent.

http://screensnapr.com/v/cn9Y2R.png

(Complete with mismatched buttons lol)

Good nice work you have madea a nice web browser .i m realy appreciate it
keep rocking bro..:)



* - LittleBrotherTrucker - May 22, 2012

(May 22, 2012 07:30 PM)Viru The Boss Wrote:  Good nice work you have madea a nice web browser .i m realy appreciate it
keep rocking bro..:)

Thanks.

Nice tutorial man.

TooShortTooShort