VB.Net - Program Structure


Before we study basic building blocks of the VB.Net programming language, let us look a bare minimum VB.Net program structure so that we can take it as a reference in upcoming chapters.

VB.Net Hello World Example

A VB.Net program basically consists of the following parts −

Let us look at a simple code that would print the words "Hello World" −

Live Demo
Imports System
Module Module1
   'This program will display Hello World 
   Sub Main()
      Console.WriteLine("Hello World")
      Console.ReadKey()
   End Sub
End Module

When the above code is compiled and executed, it produces the following result −

Hello, World!

Let us look various parts of the above program −

Compile & Execute VB.Net Program

If you are using Visual Studio.Net IDE, take the following steps −

You can compile a VB.Net program by using the command line instead of the Visual Studio IDE −