Steps for Creating a Hello World Application Using Vb.Net (Visual Studio)
In the previous articles, we learnt about the introduction to visual basic.net and parts of visual studio IDE (Integrated Development Environment.
In this guide, we are going to learn how you can create your first “Hello world” application on the Visual Studio IDE.
A vb.net “Hello World!” application is the simplest program to make in the Visual Studio Environment. It simply displays the words “Hello Word!” on the screen.
This is the first program that you should write as a beginner using vb.net programming. The vb.net “Hello World!” demonstrates the basic syntax of the programming language.
- A computer running any version of Visual Studio
- If you haven’t downloaded or installed the free version of Visual Studio, kindly refer to our vb.net getting started guide
Step 1: Launching Visual Studio
On the Start Menu select “All Programs->Visual Studio
The splash screen will be displayed for a few seconds and Visual Studio will finally open
Step 2 : Creating a new Project
Launch a new project by clicking File->New->Project
Step 3: Selecting a template
On the templates nodes, select Visual Basic. On the list of templates, select Windows Forms Application as seen on the screen below.
At the bottom of the New Project screen, you will see a “Name” text box; just enter the word HelloWorld without spaces.
Then, you need to select a location to save your project. Click Browse, then select your folder location and give it a descriptive name e.g. “HelloWorld” without quotes.
Leave the Solution name intact and click ‘OK’ to create your vb.net Hello World application
Step 4 : Add the Code
A default form will be created. We will need to add a command button on the form from the tool box.
So, on the tool box, click on the button tool and then draw it on the default form displayed.
Next, we need to paste the below code on the button’s click even. So, double click the button to switch to the code editing mode and copy paste the text below.
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Visual Studio will automatically create a class as shown above. The Class Form1 has a single method that handles our button’s click event.
The Msgbox part simply tells Visual Studio to display the words, “Hello World!” in a message box once we run our application.
Step 5: Testing the application
To run the vb.net Hello World Application, select the Debug menu then click on Start Debugging. Alternatively, you can press F5 to run the application.
Then click on the button that we created above and you should see message box displaying the worlds ‘Hello World!’ as show below.
That’s it; you have created your first Visual Basic.Net application.