Site icon Student Project Guidance & Development

How to create variables in VB.NET

How-to-create-variables

How to create variables in VB.NET

Hello, welcome to studentprojectguide.com . This is a simple program which will explain how to create variables in VB.NET. There are three main types of data types in VB.NET. The three main data types are Integer,  Double and string. In VB.NET it works in just 3 steps. First is variable initialization, Second is Declaration, and third is execution.

In this program we created variables in global form. We created three types of different variables in this source code. After creating variables in the form load event values assigned to 3 variables. In the button click even message box which displays variable values in the popup.

Steps to create this program:


Here is the source code:

Public Class Form1
    Dim num As Integer ' Integer variable without decimal points
    Dim amount As Double ' double with decimal points
    Dim custname As String ' string variable to put characters 
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        num = 100 ' Assigning integer value
        amount = 200.53 ' Assigning value with decimal point
        custname = "Rajesh kumar" ' String variable records inside quote
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        'This is to display results
        MessageBox.Show("num = " & num)
        MessageBox.Show("amount = " & amount)
        MessageBox.Show("custname = " & custname)
    End Sub
End Class

Download Source Code:

Video tutorial:  This video clearly explain how to create variables and how to display records in VB.NET.

Thanks for reading this article. If any doubts kindly post comments in the comment box.

Exit mobile version