Visual Basic .NET - Hello World Example

The "Hello World" program is a simple program that is often used to introduce beginners to programming concepts. It is a program that displays the message "Hello, World!" on the screen. Here is the code for the "Hello World" program in VB.NET:

Module Module1
    Sub Main()
        Console.WriteLine("Hello, World!")
    End Sub
End Module

Explanation of the code:

  • Module Module1: The Module keyword is used to define a module in VB.NET. A module is a collection of related functions and variables.
  • Sub Main(): This is the entry point of the program. It is the first method that is executed when the program starts. The Sub keyword is used to define a subroutine, which is a block of code that performs a specific task.
  • Console.WriteLine("Hello, World!"): This line of code displays the message "Hello, World!" on the screen. The Console class is used to interact with the command line. The WriteLine method is used to display a message on the screen and move the cursor to the next line.
  • End Sub: This marks the end of the Main subroutine.

To run the program, follow these steps:

  • Open Visual Studio.
  • Click "New Project" on the start page.
  • In the "New Project" dialog box, select "Console App (.NET Core)" under "Visual Basic" in the left pane.
  • Choose a location and name for your project, and then click "Create."
  • Visual Studio will create a new project with a default "Hello World" program. If it does not, open the Module1.vb file in the Solution Explorer and replace the code with the code shown above.
  • Press the "Start" button or hit the F5 key to run the program. The output window should display the message "Hello, World!"