You are currently viewing VB.Net Program Structure || VB.NET 2019 Best program structure

VB.Net Program Structure || VB.NET 2019 Best

Following are the program structure and we will also see structure in with example with basic examples:

  • How To Use Module
  • How To Use Classes
  • Hello Word Program
  • How To Define Structure
  • What is Microsoft Visual Studio IDE

A Module is a custom functions it is not a class it is use for container.A Module is mainly use toorganize code in a global on single place. In VB.Net By default the Sub Main is place in a Module called “Module1”.

In a project a Module is use to manage custom property of any element you will set the property in Module without property windows and it will be call any where in the project.

A VB.NET Project Consist The Following

  1. Namespace Declaration
  2. One or More Procedure
  3. A Class Or Module
  4. One Or More Variables
  5. The Main Procedure
  7. Statement & Expression

Create a program “Hello Word” program with new project console application. Here we see the basic console application in program example.

Step 01: Open Visual Studio click on file menu , choose new and then click project. Like following pics. program structure

Step 02 : On the new window select the visual basic language from the combo box selector in the left side. program structure

Step 3 : Then choose the first option Console App (.Net Core) click next. program structure

Step 04 : Enter t he name of your project in the first text box then click on create button. program structure

Step 05 : The following main screen of Visual Studio 2019 will open. In the latest version of Visual Studio 2019 the namespace automatically declared on the top and also “hello word !” message box automatically declared. program structure

Imports System
Module Module1

Sub Main()
Console.Write(“Hello Word !”)

End Sub

End Module

Step 06: Copy the above code and past in the sub main and click on the run button in the toolbar . After the successful build the following output will open with hello word with no error.

App Out Put || VB.Net Program Structure program structure

Now we describe the above console app program on by one with the following pics. program structure

Explain the above code || VB.Net Program Structure

  1. Import System: This is called the namespace declaration. What we are doing that including in namespace with the name system info our console app. After declared the namespace now we will able to access the system method . And access any module function and class in the project.
  2. Module Declaration: This is called module declaration .Here we declare a module with the fname of Module Program. VB.Net is a object oriented programming language we must have a class module in a program so you will be able to define the data in module.
  3. Comments : This is a comments before drop a comments use single quote (‘) in your line it means compiler will not execute this line.
  4. Procedure: Procedure are use to define a class, module, events, addhandler, Get, Set, RemoveHandler, And RaisEvents. In this section you define the main sub. Procedure will define the class behavour.
  5. Code : This line is use to define the code with different quires and statements. Use this to define what use input in your program in the console.
  6. This allow to the user to exit the program by pressing any key from the keyboard.
  7. End Sub (): It is use to close the sub main procedure.
  8. End Module: This line indicate the end of module.

Imports System

Module Program
Class product
Public price As Double
Public qty As Double
End Class
Sub Main()
Dim tot_amount As product = New product()
Dim total As Double = 0.0

tot_amount.price = 525.6
tot_amount.qty = 2

total = tot_amount.price * tot_amount.qty
Console.WriteLine(“The total amount is : {0}”, total)
End Sub

End Module program structure

Accepting Values From The User || VB.Net Program Structure

In VB.Net console class or module provide function ReadLine() for accepting input from the user according to given instruction define in case of variables. And these values are stored in variables . For example:

Imports System
Module Module1

Sub Main()
Dim message As String
Console.Write(“Enter your name: “)

message = Console.ReadLine

Console.WriteLine(“Your Name: {0}”, message)
End Sub

End Module program structure

In VB.Net program structure this function ask the use to input some text which define in variables it may be string, integer, decimal, double, date, currency etc. The user input the some text according to the function and these values will automatically stored in shape variables.The output screen will appear like this:- program structure program structure: program structure
  1. In the above screen out the user enter the their name
  2. The 2nd line show the out put result which is string value in declare in variable.

This Post Has One Comment

Comments are closed.