Visual Basic: String, Integer and Double Data Types
Posted: January 31st, 2012 | Author: Brian Martin (BlinkBrian) | Filed under: Visual Basic Tutorial (Series) | No Comments »In the last tutorial we looked at Visual Basic Data Types.
Variables must have a data type. The data type tells the computer how much storage space to provide. It also tells the computer the operations available.
| Data Type | Values | Operations |
| String | Any text, names, addresses, phone numbers | +, <,>,=,<> |
| Integer | Whole Numbers, i.e. 0, 1, 2, -4. Use this when you want to perform math operations. |
|
| Double | Decimal numbers ie; 10.3. Use Double when you want to perform math operations. |
Exercise – Adding decimal numbers
Open the “AddingNumbers” program. Change the data type for variables a, b, c from Integer to Double.
Test your program by using the following input data: a = 3.3 and b = 2
What is the result?
Exercise – Adding Characters
Open the “AddingNumbers” program. Change the data type for variables a, b, c from Double to String
Test your program by using the following input data: a = o and b = k
What is your result?
Exercise – Developing a basic calculator
Create a new console application and save it as “Calculator”. Using the same techniques as the “AddingNumbers” program, create a basic calculator that adds, substracts, multiplies and divides two numbers by the user.

A Possible Output Of The Calculator

In the next tutorial we look at Visual Basic String Addition – Piecing Text Together
Leave a Reply