• Convallis consequat

    Lorem ipsum integer tincidunt quisque tristique sollicitudin eros sapien, ultrices primis volutpat tempor curabitur duis mattis dapibus, felis amet faucibus...

  • Augue nullam mauris

    Lorem ipsum integer tincidunt quisque tristique sollicitudin eros sapien, ultrices primis volutpat tempor curabitur duis mattis dapibus, felis amet faucibus...

  • Donec conubia volutpat

    Lorem ipsum integer tincidunt quisque tristique sollicitudin eros sapien, ultrices primis volutpat tempor curabitur duis mattis dapibus, felis amet faucibus...

  • Primis volutpat tempor

    Lorem ipsum integer tincidunt quisque tristique sollicitudin eros sapien, ultrices primis volutpat tempor curabitur duis mattis dapibus, felis amet faucibus...

VB.Net Variables

In VB.Net a Variable can be dependent and independent variables. It can be a symbolic name associated with any value and can be used to store any data types like String, Boolean, Integer, Byte, etc.

In this tutorial, we'll help you understand what is the purpose of using variables, how to create and use them in your program.

Independent Variables
Let's take a look at the following code below to illustrate a usage of independent variables.
Public Class Form1
    Dim GuestName As String = "Jhon Doe"
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MessageBox.Show("Hello " & GuestName & "! How are you today?", "Greetings")
    End Sub
End Class

This line of code simply means that we declare a String variable named GuestName and set its value to "Jhon Doe".
Dim GuestName as String = "Jhon Doe"

When the button on the form is clicked this line of code is executed. This means that it will show a message box saying "Hello Jhon Doe! How are you today?".
MessageBox.Show("Hello " & GuestName & "! How are you today?", "Greetings")
You might be asking how but this is how the code was interpreted. The GuestName variable will grab the value we declared which is "Jhon Doe" and put it in the message instead.

Dependent Variables
Let's take a look at the following code below to illustrate the usage of dependent variables.
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim RoomWidth As Integer = InputBox("Please input the width of the Room:", "Width")
        Dim RoomLength As Integer = InputBox("Please input the length of the Room:", "Length")         
        Dim RoomArea As Integer = RoomLength * RoomWidth
        MessageBox.Show("The total area is " + RoomArea.ToString())
    End Sub
End Class

The above codes means that when the user clicks the button, it will prompt the user to input the Length and Width of a Room. Calculate the Room's Area and show the total area to the user.

The variables RoomWidth and RoomLength are considered as independent variables. While the variable named RoomArea is considered as the dependent variable. Because it will require the user to enter values to both variables otherwise, there will be an execution error.

The line of code below calculates the value entered in the RoomLength and RoomWidth variables.
Dim RoomArea As Integer = RoomLength * RoomWidth

The line of code below will simply display the result value of the variable named RoomArea.
MessageBox.Show("The total area is " + RoomArea.ToString())
You might be asking why there's a .ToString() after the RoomArea. That is because if we combine a strings with a variable containing numbers in a MessageBox we need to convert it to string.

VB.Net Identifiers

An identifier is a name used to identify a class, variables, functions, procedures, or any other user-defined item. The basic rules for naming classes in VB.Net are as follows:
  • A name should begin with a letter that could be followed by a sequence of letters, digits (0 - 9) or underscore. The first character in an identifier cannot be a digit or number.
  • It must not contain any special character, space or symbol like ? - +! @ # % ^ & * ( ) [ ] { } . ; : " ' / and \. However, an underscore ( _ ) can be used.
  • It should not be a reserved keyword.

VB.Net Reserved Keywords

The table below shows the list of the reserved keywords in VB.Net
AddHandler AddressOf Alias And AndAlso As Boolean
ByRef Byte ByVal Call Case Catch CBool
CByte CChar CDate CDec CDbl Char CInt
Class CLng CObj Const Continue CSByte CShort
CSng CStr CType CUInt CULng CUShort Date
Decimal Declare Default Delegate Dim DirectCast Do
Double Each Else ElseIf End End If Enum
Erase Error Event Exit FALSE Finally For
Friend Function Get GetType GetXML Namespace Global Goto
Handles If Implements Imports In Inherits Integer
Interface Is IsNot Let Lib Like Long
Loop Me Mod Module MustInherit MustOverride MyBase
MyClass Namespace Narrowing New Next Not Nothing
Not Inheritable Not Overridable Object Of On Operator Option
Optional Or OrElse Overloads Overridable Overrides ParamArray
Partial Private Property Protected Public RaiseEvent ReadOnly
ReDim REM Remove Handler Resume Return Sbyte Select
Set Shadows Shared Short Single Static Step
Stop String Structure Sub SyncLock Then Throw
To TRUE Try TryCast TypeOf UInteger While
Widening With WithEvents WriteOnly Xor

My First VB.Net Application (Hello World Example)

In this tutorial, we'll help you create your first Application in VB.Net. In most programming language this is the most commonly used example when writing the first program. To narrow it down, we'll create a simple application that will display a message box saying "Hello World".

Follow the steps below:

1) On the Visual Basic 2010 Express start up window, Open the File Menu then Select New Project. Or Press Ctrl+N.

2) The following window will then pop up. In the Applications type, choose Windows Forms Applications. And type the desired name of your application in the name box, in this example we put "My First Application". Then click OK.

3) When the project is successfully created, Add a Button control on to the Form.

4) Now, double click the Button control and you will see the Code Editor window which already has the Click event of the button control automatically added. Update the code to exactly look as below.
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MessageBox.Show("Hello World!")
    End Sub
End Class
5) Press F5 to compile and run the program. You can now see the form.

6) Click the Button on the form and you will surely smile of the message as you have finally created your first VB.Net application.

Integrated Development Environment (IDE) for VB.Net

After you have downloaded and installed Visual Basic 2010 Express Edition, Using the IDE tools, you can write all kinds of VB.Net programs from simple command-line applications to more complex applications.

1) Go to Start Menu and look for the Microsoft Visual Studio 2010 Express in the Programs folder and click Microsoft Visual Basic 2010 Express to start the Program.

2) After the application is launch this will be the look of the IDE.

Download Visual Basic 2010 Express

To download Visual Basic 2010 Express, follow the steps below.

1) Open your Internet Browser.

2) In the address bar, type "http://www.visualstudio.com/en-us/downloads#d-2010-express" then press Enter. Or click this download link.

3) The page will automatically navigate to the 2010 Express Download section as you can see below.

4) Click Visual Basic 2010 Express to see more options.

5) Click the "Install Now" link. The vb.net installer will now be downloaded.

6) When the download is finish, open the download folder location and Double Click to Open the File.

7) When prompted with, just Click the Run button.

8) The setup will then extract the package and begin the installation. Just follow the on screen instruction to finish the installation process.

VB.Net Introduction

VB.Net - Visual Basic is an Object-Oriented Programming commonly known as OOP created by Microsoft which is implemented on .NET Framework. Although this language is targeted for beginners because of its simplicity, there are still powerful tools and applications that can be created using this language.

Some examples may include but not limited to Animations, Games, Graphics, Financial Calculators, Database Applications, Inventory Management Systems, Multimedia Player, Web Applications and many more. It is on your own creativity how you can implement and create such powerful tools.

For beginners VB.Net is an absolute language to start with aside from its simplicity it is also straight forward.

Applications compiled with VB.Net can not just run on Windows, it is also possible to run them on Linux and Mac Operating Systems.

Here are some reasons of why VB.Net is widely used as programming language.
  1. Easy to Learn
  2. Object Oriented
  3. Component Oriented
  4. Modern and general purpose
  5. Structured language
  6. Creates efficient and powerful programs
  7. Can be compiled on several computer platforms
  8. Belongs on .NET Framework
Since, it is implemented on .NET Framework it has access to variety of libraries which can be used when creating programs.

VB.Net Extended Features

  • Automatic Garbage Collection
  • Assembly Version
  • Boolean Conditions
  • Conditional Compilation
  • Delegates and Events Management
  • Indexers
  • Multithreading
  • Properties and Events
  • Standard Library