Visual Basic tutorial: Hello world
This tutorial helps you get started with Visual Basic. It explains what you need to write your first Visual Basic program. It starts with the basics: you will learn where you can find and download the tools needed, how to install these tools and it will take you all the way to building and runing your code. If you have never written a Visual Basic program before this is the place to start. We have created this article, so you can get started with Visual Basic, and move on to our sms examples. If you are already familiar with Visual Basic, you can jump directly to one of the following SMS projects.
VB sms examples:
VB send sms with the HTTP rest api (code sample)
VB send multiple sms with the HTTP rest api (code sample)
VB schedule sms with the HTTP rest api (code sample)
VB receive sms with the HTTP rest api (code sample)
VB delete sms with the HTTP rest api (code sample)
Download the latest Visual Basic sms api library from Github
What is Visual Basic
Visual Basic is a programming language. It is similar to a natural language, like English. It is used to talk to a computer. The major difference between a natural language and a programming language is that, programming languages have a more rigorous structure, to help the computer understand it better.
What is Visual Studio
Visual studio is a tool to write a Visual Basic program. Visual studio allows you to type in text using the Visual Basic language, and it makes it possible for you to tell the computer, to read the text and execute the instructions. We use the term "Run" to tell computer to execute the instructions.
What is a Visual Basic Hello world program
The Visual Basic hello world program is the most simple program you can write. It simply prints out the sententce: Hello world on the computer screen. The Hello World program is the first program developers write in any programming language.
How to write your first program in Visual Basic
To write your first program in Visual Basic:
- Setup Visual Studio
- Create a new Visual Studio project
- Select Console Application
- Name the project
- Choose .NET for Target Framework
- Write Hello World program in Visual Basic
- Run the Hello World program
- Check the output
Here is what you need to get started. To write your first computer program in Visual Basic, you need a Windows computer, the Visual Studio programming environment and example code presented below.
- Windows 10 computer
- Microsoft Visual Studio Community Edition
- Ozeki Hello World example project
Download Visual Studio (Video tutorial)Microsoft Visual Studio Community Edition
In this video, we are going to show you how to download Visual Studio. It will start with opening your browser and will take you all the way to having the installer on your computer. You will learn what page to visit and what button to look for if you want a free version of the software. This video is only 40 seconds long but it contains all the information you need to download the Microsoft Visual Studio Community Edition. You may download the installer from the following URL: https://visualstudio.microsoft.com/downloads/.
Install Visual Studio (Video tutorial)
In the following video, you will be presented with the process of installing Visual Studio. The video will start with the opened downloads folder with the installer visible there. At the end of the video, you will have a copy of Visual Studio installed on your computer. We assume that you already downloaded the installer file. You will learn what to do in each of the steps and how to set up the program. This video is only 2:40 long and it is very detailed. You can get all the information you need from it.
Create your first visual studio project (Video tutorial)
From this video, you will learn how to create a new project in Visual Studio. The video will start with opening the Visual Studio for the first time. At the end of the video, you will have a project that you can start to work with. You will also learn what settings you need to do to have a usable project file. The video itself is only 41 seconds long, very detailed, and easy to follow. You will have no problem with understanding the steps.
Create a new project
First, open Visual Studio, which you have just installed. You will be then greeted by a welcome screen. This screen lets you create a new project or open previous ones. Under the "Get Started" column on the right, click on Create a new project (Figure 1). This will forward you to the next page where you can configure the settings of your project.
Choose VB Console Application
After you have clicked on "Create a new project" you will be brought to a configuration screen. In order to create an Visual Basic, you will first need to select the Visual Basic Console Application template (Figure 2). Click on this option to select it. Then, click on the Next button on the bottom left to continue.
Name your project
After specifying your project as a Console Application, you will be asked to give it a name. Under the text that reads "Project name" you will find a textbox (Figure 3). Enter your desired name into this textbox to name your project. Give it an easily identifyable and fitting name, so you could always recognize it. Click on the Next button on the bottom right when you are done.
Choose target framework
To finalize your project configuration you need to select a targeted framework. This can be done on the last configuration page. You can select a targeted framework from the combobox by clicking on it (Figure 5). Here we select .NET Core 3.1. This is a good choice for your project. Click on the Create button on the bottom right to create your project.
Write your 'hello world' program in Visual Basic
The first program you write in any programming language is the 'Hello world' program. The sole aim of this program is to print the term 'Hello world' to the computer screen. In this example the program consists of two lines of code: The first line: Console.WriteLine prints the text.
Imports System Module Program Sub Main(args As String()) Console.WriteLine("Hello World!") End Sub End Module
Run the Visual Basic 'hello world' program (Video tutorial)
From this video, you will learn how to run your code. The video will start with a written hello world code. At the end of the video, you will see the output of this code in a command prompt. The video is only 12 seconds long and you can see the whole process on it. You will have no problem with understanding it. To run the hello world program, you need to click on the green Start button in the Visual Studio toolbar. You may also use the F5 key to run your program. Note that when you press F5, visual studio will first save your newly written file, then it will copmile it to an executable code, and then it will run it on your computer.
Run the program
To run the hello world program, you need to click on the green Start button in the Visual Studio toolbar. This executes the code you wrote in the text editor on your computer. It will open a new window where you can view the output of your code (Figure 5).
Output of your code (Video tutorial)
In the following video, you will see the output of the created code. First, you will see an unchanged text visible in a command prompt. At the end of this 15 seconds video, you will see the changed text. In the process, you will learn how to modify the code in a way that it prints out a customized text. The video itself is very detailed and easy to understand. You will have no problem with finishing the process.
"Hello World!" output
After you have instructed Visual Studio to run you program a debug console will pop up. In this debug console you can see your program run in real time. This looks very much like a regular Windows command prompt. The first line you see is the output of your code: "Hello World" (Figure 6). Then, 3 lines further down, you will see "exited with code 0". This means your program has closed. To close the console itself, press any key on your keyboard.
What happens if I make a mistake in Visual Basic
If you make a mistake, when you write your instructions in Visual Basic, you will get a Syntax error. The computer will highlight the line with error in red, and it will tell you why didn't it understand the instructions. To correct the mistake you need to go back to the text editor and modify the program. Programs say they "fix the error" when they correct mistakes.
What is syntax error in Visual Basic?
Syntax error means I don't understand. If you talk to somebody in English and he does not understand what you say, he will reply with "I don't understand". If you talk to a computer in Visual Basic and the computer does not understand what you say, he will reply with "Syntax error".
In this video below we will create a mistake intentionally by not putting a semicolon after the Hello World line. You will see, how the computer reacts, how we fix the error, and how we run the computer program successfully.
How to handle a syntax error in VB? (Video tutorial)
In the following 27 seconds long video, you will see how to handle syntax errors in Visual Basic. You will learn how to find and how to fix errors in the code. In the first part of the video, you will see a code with a purposeful syntax error. At the end of the video, you will see the corrected code. The video is only 27 seconds long but it explains the process in a very detailed way. You will have no problem with following it.
Errors in Visual Basic
When you make a mistake in the code, there are multiple ways Visal Basic will notify you. First of all, lines that will lead to errors are underlined in red in the text editor (Figure 7). If you decide to run the program anyway, the Output console on the bottom of the screen will list all of the errors. These listings contain an explanation of the problem itself, so it is easier for the programmer to identify the problem and fix it.
Now that you have completed the five simple steps above, you have made your first step in becoming a VB.Net software developer. This program may seem simple, and it may not do much, but this is how great things start. Every programming course starts here, be patient and the hard work will definitely pay off.
Visual Basic is an easy to learn event-driven programming language. It is mainly used for creating software interfaces and helps accessing databases. The next step in your learning journey will be creating an HTTP request.
Now download Ozeki SMS Gateway for the next part of VB programming and let the work begin!
- C# SMS tutorial: Hello world
- F# SMS tutorial: Hello world
- Java SMS tutorial: Hello world
- Node.js SMS tutorial: Hello world
- Kotlin SMS tutorial: Hello world
- C/C SMS tutorial: Hello world
- Delphi SMS tutorial: Hello world
- PHP SMS tutorial: Hello world
- Perl SMS tutorial: Hello world
- Python SMS tutorial: Hello world
- Python flask SMS tutorial: Hello world
- Ruby SMS tutorial: Hello world
- Tcl/Tk SMS tutorial: Hello world
- Go SMS tutorial: Hello world
- R SMS tutorial: Hello world
- Scala SMS tutorial: Hello world
- Objective C SMS tutorial: Hello world
- Tutorials for software developers