How to Create a Program to Print Out the Sums in Visual Basic Studio
Learning how to create a console program in Visual Studio to print out the sum of two numbers can be the first step to becoming proficient in using Visual Studio. You can use multiple computer programming languages in Visual Studio such as C# and Visual Basic.NET (VB.NET), among others. A VB.NET console application is one of the simplest applications to create in Visual Studio, but it also can be used to solve complex problems. You can retrieve information from the console window to be used in your program, and you can print out the results.
Instructions
-
-
1
Launch Microsoft Visual Studio. Click “File,” select “New Project” and then expand “Visual Basic.” Click “Windows” and double-click “Windows Console Application” to create a new project.
-
2
Add the following code to create three new variables:
Dim firstNum As Integer
Dim secondNum As Integer
Dim sumResult As Integer -
-
3
Copy and paste the following code to prompt the user to enter two numbers to sum and save the values in two different variables:
Console.WriteLine("Please enter the first number to sum:")
firstNum = Console.ReadLine()
Console.WriteLine("Please enter the second number to sum:")
secondNum = Console.ReadLine() -
4
Get the sum of the two numbers by adding the following code:
sumResult = firstNum + secondNum
-
5
Print out the sum result to the console window by adding the following code:
Console.Write("The sum of your two numbers is: " & sumResult)
Console.ReadLine() -
6
Press the “F5” key to run the program.
-
1
References
- Photo Credit Comstock/Comstock/Getty Images