Steps for Creating a Hello World Application Using Vb.Net (Visual Studio)

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.

Prerequisites

  • 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

        MsgBox("Hello World!")

    End Sub

End Class

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.

Parts of a VB.NET Integrated Development Environment (IDE)

To start Vb.net from your computer, go to Start Menu->All Programs->Visual Studio (2015). A splash screen will display for a view seconds and finally, a dashboard will be displayed.

Then click on the File menu and select “New project”

On the template (Top left of the form), select Visual Basic and make sure “Windows Form Application” is selected as shown on the image below.

You may also change the .net framework that you are targeting on the middle top part of the “New Project” screen. However, the default .net Framework 2.0 should work for light-weight programs.

At the bottom, you will see a textbox for naming your project; just use a self descriptive name like ‘MyFirstApp’. Also, you need to select a folder where your project’s file will be saved. The solution name will be filled by default and you can leave it that way. Then click ‘OK’ to start the new project.

Parts of a VB.NET Integrated Development Environment (IDE)

File Menu

You can use the file menu to save or open your vb.net project, edit, find and replace text. You can also use the View Menu to display the toolbox or solutions explorer if they are not visible. The project menu is used to add new forms, classes or modules.

Tool bar

The tool bar contains different shortcuts for opening/saving projects as well as running your project once it is ready for debugging.

Status Bar

It appears on the bottom of the vb.net IDE. It displays the status of the current operation. By default, it will display a “Ready” status but this will change once your run the application.

Solutions explorer

The solutions explorer appears at the right-most part of the vb.net IDE. It displays all the objects that you are using on your project including your forms, datasets, reports, modules, references and different resources that you have used on your project

Tool box

The vb.net tool box displays different visual objects/tools that you can use on your form. The most common tools include:

  • Label
  • Textbox
  • Command Button
  • Radio button
  • Checkbox
  • Listbox
  • Combo box
  • Picture box
  • Date & Time Picker and
  • Progress Bar

If you want to use any of the above controls, just click it and point your mouse on the default form to draw the control.

Once you have mastered the parts of a Visual Studio IDE, we need to proceed to creating the first vb.net software – the Hello World! Application 

Introduction to Visual Basic.Net

Visual Basic.Net is a programming language that was released by Microsoft in 2002. Its predecessor was Visual Basic. To program using Vb.Net, programmers use an Integrated Development Environment (IDE) known as Visual Studio.

Although there is an Enterprise version of Visual Studio, a programmer can use  free editions such as Visual Studio Express and Community Edition which can be downloaded for free from the Microsoft Website.

The ‘”VISUAL” part refers to the aspect of programming using a graphical user interface to choose, draw and even modify a code written in BASIC programming Language.

BASIC is an acronym for Beginners All Purpose Symbolic Instruction Code that was designed in 1964 by John G. Kemeny, Thomas E. Kurtz and Mary Kenneth Keller in a United States school – Dartmouth College. BASIC is an all purpose high level programming language that is easy to use.

.Net is a framework of libraries designed by Microsoft to run primarily on the Windows Operating System. When a programmer creates a program using the .net framework, it is executed in an environment known as Common Language Runtime (CLR).

The .net library provides programmers with access to a user interface, data management tools, cryptography, numeric algorithms, web applications as well as network connectivity.

Visual Basic.Net is easy to learn and write code with hence there are lots of working programs already written on that language. It is estimated that about 3 million programmers utilizes the .net framework to design, code and implement professional applications.

Programming with Visual Studio.Net

To start using Vb.net, download the community edition . You can choose between Visual Studio 2015 and Visual Studio 2017. The two works fine.

Also make sure that your computer has the following system requirements:

  • 6 GHz or faster processor
  • 1 GB of RAM (1.5 GB if running on a virtual machine)
  • 4 GB of available hard disk space
  • DirectX 9-capable video card (1024 x 768 or higher resolution)

Installing Visual Studio.Net

Once the download is complete, you need to install Visual Studio on your computer. You may be prompted to install additional components during the installation.

When the installation is complete, you can launch Visual Studio from Start menu -> Programs.

Start Visual Studio.net

In the next section, we are going to learn about the different parts of a Visual Basic.net IDE.