Creating Your First Visual Basic Program
This page is specific to:.NET Framework Version:2.03.5
Visual Basic Guided Tour
Creating Your First Visual Basic Program

The best way to learn programming with Visual Basic is to actually create a program. The following exercises discuss the process of creating a program for viewing Web pages.

If you don't understand everything immediately, don't worry—the concepts introduced here will be discussed in detail in other sections of the Visual Basic Guided Tour.

link to video For a video version of this topic, see Video How to: Creating Your First Visual Basic Program.

In This Section

Step 1: Create a Project in Visual Basic

Describes how to create a project for your Web-browsing program.

Step 2: Create a User Interface

Describes how to add controls to the form to create the user interface of the Web-browsing program.

Step 3: Customize Looks and Behavior

Describes how to change the properties of the controls on the Web-browsing program.

Step 4: Add Visual Basic Code

Describes how to add code to the event handler of a button in the Web-browsing program.

Step 5: Run and Test Your Program

Describes how to run the Web-browsing program to test its functionality.

Related Sections

Closer Look: Understanding Properties, Methods, and Events

Provides an overview of the methods, properties, and events of an object.

Closer Look: Understanding Control Layout

Describes how to arrange, align, and resize controls on a Windows form.

Project Types in Visual Basic Express

Describes the project types available in Visual Basic Express.

Introduction to the Visual Basic Programming Language

Introduces the basics of the Visual Basic language.

Creating the Visual Look of Your Program: Introduction to Windows Forms

Describes how to use forms and controls to create a user interface.

Community Content

List of Different Code for Making a Web Browser in Visual Basic
Added by:janersa

Private Sub tbToolBar_ButtonClick(ByVal Button As MSComctlLib.Button)

End Sub

Private Sub cboAddress_Click()

webNavigate.Navigate cboAddress.Text

End Sub

Private Sub cmdFavorites_Click()
CboAddress.AddItem CboAddress.Text
End Sub


Private Sub cmdGo_Click()
WebBrowser1.Navigate CboAddress
End Sub


Private Sub CmdEnd_Click()
WebBrowser.Visible = False
Main.Visible = True
End Sub

Private Sub cmdHome_Click()
WebBrowser1.Navigate "http://www.google.com"
cboAdresse = WebBrowser1.LocationURL
End Sub

Private Sub cmdMail_Click()
WebBrowser1.Navigate "http://www.hotmail.com"
End Sub

Private Sub cmdBack_Click()
On Error GoTo Error
WebBrowser1.GoBack
Error:
Exit Sub
End Sub

Private Sub cmdRefresh_Click()
WebBrowser1.Refresh
End Sub

Private Sub cmdStop_Click()
WebBrowser1.Stop
End Sub

Private Sub cmdForward_Click()
On Error GoTo Error
WebBrowser1.GoForward
Error:
Exit Sub
End Sub

Private Sub cboAddress_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdGo_Click
End If
End Sub

Private Sub WebBrowser1_TitleChange(ByVal Text As String)

CboAddress = WebBrowser1.LocationURL
End Sub

Private Sub Address_Change()
WebBrowser1.Navigate Text1
End Sub

Private Sub Go_Click()
WebBrowser1.Navigate Address
End Sub

google
Added by:Reidam
Private Sub tbToolBar_ButtonClick(ByVal Button As MSComctlLib.Button)

End Sub

Private Sub cboAddress_Click(www.google.co.uk)

webNavigate.Navigate cboAddress.Text

End Sub

Private Sub cmdFavorites_Click(www.mymaths.co.uk)
CboAddress.AddItem CboAddress.Text
End Sub


Private Sub cmdGo_Click(www.runescape.com)
WebBrowser1.Navigate CboAddress
End Sub


Private Sub CmdEnd_Click(www.clubpenguin.com)
WebBrowser.Visible = False
Main.Visible = True
End Sub

Private Sub cmdHome_Click(www.bing.com)
WebBrowser1.Navigate "http://www.google.com"
cboAdresse = WebBrowser1.LocationURL
End Sub

Private Sub cmdMail_Click(www.miniclip.com)
WebBrowser1.Navigate "http://www.hotmail.com"
End Sub

Private Sub cmdBack_Click(www.microsoft.com)
On Error GoTo Error
WebBrowser1.GoBack
Error:
Exit Sub
End Sub

Private Sub cmdRefresh_Click(www.spec.org.uk)
WebBrowser1.Refresh
End Sub

Private Sub cmdStop_Click(www.bbc.co.uk)
WebBrowser1.Stop
End Sub

Private Sub cmdForward_Click(www.itv.co.uk)
On Error GoTo Error
WebBrowser1.GoForward
Error:
Exit Sub
End Sub

Private Sub cboAddress_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdGo_Click
End If
End Sub

Private Sub WebBrowser1_TitleChange(ByVal Text As String)

CboAddress = WebBrowser1.LocationURL
End Sub

Private Sub Address_Change()
WebBrowser1.Navigate Text1
End Sub

Private Sub Go_Click()
WebBrowser1.Navigate Address
End Sub

pls use this code
Added by:Easytime

Public Class Form1
Private Sub Calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calculate.Click
Dim A As Double = TextBox1.Text
Dim B As Double = TextBox2.Text
Dim calc As String = TextBox3.Text
Dim C As Double
If TextBox3.Text = "+" Then
C = A + B
ElseIf TextBox3.Text = "-" Then
C = A - B
ElseIf TextBox3.Text = "*" Then
C = A * B
Else : C = A / B
End If
result.Text = C



End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
Close()
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub plus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles plus.Click
Dim plus As String = "+"
TextBox3.Text = plus

End Sub
Private Sub minus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles minus.Click
Dim minus As String = "-"
TextBox3.Text = minus
End Sub
Private Sub mult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mult.Click
Dim mult As String = "*"
TextBox3.Text = mult
End Sub
Private Sub div_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles div.Click
Dim div As String = "/"
TextBox3.Text = div
End Sub
End Class
Mobile Calclator Program
Added by:Easytime

//you can download the application free with the source code from www.empretecnigeriafoundation.org/design/vb.asp

Public Class easycalc
Private Sub Calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calculate.Click
Dim A As Double = _numA.Text
Dim B As Double = _numB.Text
Dim calc As String = oprator.Text
Dim C As Double
If oprator.Text = "+" Then
C = A + B
ElseIf oprator.Text = "-" Then
C = A - B
ElseIf oprator.Text = "*" Then
C = A * B
Else : C = A / B
End If
result.Text = C
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
_numA.Text = ""
_numB.Text = ""
oprator.Text = "+"
result.Text = 0
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub plus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles plus.Click
Dim plus As String = "+"
oprator.Text = plus

End Sub
Private Sub minus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles minus.Click
Dim minus As String = "-"
oprator.Text = minus
End Sub
Private Sub mult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mult.Click
Dim mult As String = "*"
oprator.Text = mult
End Sub
Private Sub div_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles div.Click
Dim div As String = "/"
oprator.Text = div
End Sub

Private Sub cmdexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdexit.Click
Close()
End Sub
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _numB.TextChanged
End Sub
End Class

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View