O'Reilly logo

Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition by Harvey M. Deitel - Deitel & Associates, Inc., Paul J. Deitel - Deitel & Associates, Inc.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.5. Adding Integers

Our next program (Fig. 3.16) inputs two integers (whole numbers) entered at the keyboard by a user, computes the sum of these integers and displays the result. As the user enters each integer and presses the Enter key, the integer is read into the program and added to the total.

Figure 3.16. Addition program that adds two integers entered by the user.
					1
					' Fig. 3.16: Addition.vb
					2
					' Addition program.
					3
					4
					Module Addition
 5
					6
					Sub Main()
 7
					8
					' variables used in the addition calculation
					9
					Dim number1 As Integer
					
					10
					Dim number2 As Integer
					
					11
					Dim total As Integer
					
					12
					13
					' prompt for and read the first number from the user
					14
					Console.Write("Please enter the first integer:")    
					15
					number1 = Console.ReadLine()                        
					16
					17
					' prompt for ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required