![]() |
|
SIMPLE BROWSER IN VB.NET - Printable Version +- Sinisterly (https://sinister.li) +-- Forum: Coding (https://sinister.li/Forum-Coding) +--- Forum: Visual Basic & .NET Framework (https://sinister.li/Forum-Visual-Basic-NET-Framework) +--- Thread: SIMPLE BROWSER IN VB.NET (/Thread-SIMPLE-BROWSER-IN-VB-NET) |
SIMPLE BROWSER IN VB.NET - Psycho_Coder - 04-10-2012 First start up your Integrated Development Environment(IDE). In this tutorial I will be using MS Visual Basic 2010 Express Edition. Create a new Project by clicking File > New Project or ctrl + N for windows. You will then be prompted with a new form. We will transform this simple form and make a web browser change its property according to the following: Text – My Web Browser Form Name If you can’t see your toolbox then in the Menu bar just click View > Other Windows > Toolbox or hit ctrl+alt+x for windows. Web Browser Tool Go on to the toolbox and double click the WebBrowser tool. You will see that the WebBrowsertool will occupy the whole form.For us to resize the WebBrowser, we have to undock it from the parent container. Select the WebBrowser and then clicking the right arrow head on the top right part of the form will show you “undock in parent container” option. Click that. Undock the Web Browser Now click again the WebBrowser and then try to resize it according your heart’s desire using your mouse. Now change the URL property to a website that you want to visit. In this vb example I used google.com. Url – google.com Set the Url Property We can now try this one first. But before we do that make sure that you are connected to the internet. You must now be able to visit google.com. Web Browser Home page ![]() The Codes Let’s add a new button. We will try to navigate away from google using this button. Change it’s properties according to the following: Text – Go Name – GoBtn Double click the button to create a trigger. You will see that a private sub will be created for you. In between the private sub and end sub type in this code. WebBrowser1.Navigate("facebook.com") You should now have something like this. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click WebBrowser1.Navigate("facebook.com") End Sub You can replace this line to anything website address that you want. "facebook.com" So if that’s perfectly navigating you away from google and bringing you to the website that you have specified, we are now ready to move one. Of course we don’t want to make a web browser that is difficult to use. We need a way to make things easier for our user to change into different websites. The solution there is the address box. The address box will serve as user input for the web address that they want to access. The Address Bar So to add a textbox click the textbox tool from the toolbox. Drag and drop it to our form then change the following attributes. Name – addressTxt Change the Textbox Property Then go back to our button and change this line WebBrowser1.Navigate("facebook.com") to this WebBrowser1.Navigate(addressTxt.Text) This simply means that we want to navigate to what ever is the text value of addressTxt. Now try the web browser. Go to different websites like facebook, youtube, and google. Extra Buttons Web Browser Navigation Buttons Of course we also need a way for our users to navigate back and forward from web pages. We should also add other basic buttons like refresh and stop. So let’s try to do this. First add 4 different buttons with the following attributes. Button 1 Name: BackBtn Text: Back Size: 40, 40 Button 2 Name: RefreshBtn Text: Refresh Size: 40, 40 Button 3 Name: StopBtn Text: Stop Size: 40, 40 Button 4 Name: ForwardBtn Text: Forward Size: 40, 40 Next. Double click the buttons to create a new trigger and add these codes. For BackBtn WebBrowser1.GoBack() For RefreshBtn WebBrowser1.Refresh() For StopBtn WebBrowser1.Stop() For ForwardBtn WebBrowser1.GoForward() That should work perfectly now. ![]() Final Touches We can now fix the overall appearance of our application. You can try to add an image for the buttons. You can found lots of cool icons here at IconArchive. To make our program follow the size of the window, apply the following anchor attributes: Anchor Attribute Web Browser Anchor : Top, Bottom, Left, Right Navigation Buttons Anchor : Top, Left Address Textbox Anchor: Top, Left, Right Go Button Top, Right Source:- I found this tutorial and I have posted it here,I don't exactly know from where I took this, But later on I will make a detailed thread on this topic RE: SIMPLE BROWSER IN VB.NET - enanobp - 05-17-2012 thanks for this! 24 chars.. RE: SIMPLE BROWSER IN VB.NET - COLl1D3 - 05-17-2012 Yep, thanks for this too! RE: SIMPLE BROWSER IN VB.NET - 338billy83 - 01-21-2013 thanks dude xxxxxx,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, |