VB.NET Hello World ProgramIn the previous topic, we have installed Visual Studio 2019 and created a console-based project with the name MYConsoleApp1. Now in this project, we will create our Hello world VB.NET program. A VB.NET define the following structure to create a program:
Create a Hello_Program.vb file in MYConsoleApp1 project and write the following code: Hello_Program.vb Let's compile and run the above program by pressing the F5 key, we get the follwoiing output. Output: An Alternate method to compile and execute the VB.NET programWe can also compile and execute the VB.NET program using the Command prompt instead of using the Visual Studio IDE. Step 1: After creating and saving the Hello_Program.vb file in the MYConsoleApp1 project, open the command prompt and execute the commands, as we have shown in the prompt. In place of MYConsoleApp1you can write your project name. Step 2: After that, write vbc Hello_Program.vb, as shown below. Step 3: If there is no error found at compile-time, it transfers the control in the next line for generating the Hello_Pogram.exe file. Step 4: Type Hello_Program to run the program. We get the following output. Output: Hello, Welcome to the world of VB.NET. Now we will understand the basic structure of the VB.NET program:
Create a VB.NET program using Windows FormIf you want to create a new Window-based project in Visual Studio, follow the steps given below: Step 1. Start the Visual Studio IDE. Step 2. To create a project, click on File -> choose-> New-> Project The following window appears on the screen. Step 3: Select Windows Forms App (.NET Framework) and click on the Next button. Step 4: Provide the Project name and location to store the project file using the browse button in Location. Step 5: Click on the Create button. The following window appears on the screen. Step 6: Now double click on the middle area of Form1.vb (Design) file, it shows the following code. Form1.vb Step7: Save file as Form1.vb. Step 8: To compile and run the Form1.vb file, press F5 button or Start button in Visual Studio. It shows the following output. Next TopicVB.NET Keywords |