How to Create a Simple Addition Using Console Application in VB.net

Submitted by: 
Visitors have accessed this post 81 times.

In writing a program, there are times that you have to deal with the input and output process. The question is what kind of method you have to use to work it. So, in this tutorial I will teach you how to create a simple addition using console application in VB.net. This simple method will help you process the command line itself to find out what kind of output the user wants to prompt.

Creating Application

Step 1

Open Microsoft Visual Studio 2015 and create a new console application.
ps1

Step 2

Write this following code for the input and output of the program.

  1. 'DECLEARING VARIABLE
  2. Dim num1
  3. Dim num2
  4. Dim total
  5.  
  6. 'WRITES THE SPECIFIED STRING VALUE
  7. Console.WriteLine("Input first number : ")
  8. 'READ THE NEXT LINE OF CHARACTER FROM THE STANDARD INPUT STREAM
  9. num1 = Console.ReadLine()
  10. 'WRITES THE SPECIFIED STRING VALUE
  11. Console.WriteLine("Input second number : ")
  12. 'READ THE NEXT LINE OF CHARACTER FROM THE STANDARD INPUT STREAM
  13. num2 = Console.ReadLine()
  14. 'FORMULA FOR ADDITION
  15. total = Val(num1) + Val(num2)
  16. 'WRITE THE OUTPUT FOR ADDITION
  17. Console.WriteLine("Total is : " & total)
  18. Console.ReadLine()

Step 3

Full source code.

  1. Module Module1
  2.  
  3. Sub Main()
  4. 'DECLEARING VARIABLE
  5. Dim num1
  6. Dim num2
  7. Dim total
  8.  
  9. 'WRITES THE SPECIFIED STRING VALUE
  10. Console.WriteLine("Input first number : ")
  11. 'READ THE NEXT LINE OF CHARACTER FROM THE STANDARD INPUT STREAM
  12. num1 = Console.ReadLine()
  13. 'WRITES THE SPECIFIED STRING VALUE
  14. Console.WriteLine("Input second number : ")
  15. 'READ THE NEXT LINE OF CHARACTER FROM THE STANDARD INPUT STREAM
  16. num2 = Console.ReadLine()
  17. 'FORMULA FOR ADDITION
  18. total = Val(num1) + Val(num2)
  19. 'WRITE THE OUTPUT FOR ADDITION
  20. Console.WriteLine("Total is : " & total)
  21. Console.ReadLine()
  22. End Sub
  23.  
  24. End Module

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.