VB data types
Go back to: Visual Basic.Net resources => VB syntax
For further information look in the VB.Net Help system under Data Type Summary
Data Types in VB.Net
Visual Basic has several different data types available for storing different sorts of data values. It is important that data is stored in the correct type of variable.
Main data types
Data can be divided into two main groupings:
- Numeric data - which can be used to perform calculations
- Non-numeric data - such as names, addresses, etc
In general, the distinction is simple - if the data value is a number then it is numeric data. But this does not always work, there are times when it is better to store some numbers as non-numeric values.
If in doubt - ask yourself: Will I want to perform calculations on this value?
- If Yes - then use a numeric variable.
- If No - then use a non-numeric variable.
What sort of data is a telephone number? e.g. 01902 321234 The number is made up of digits, but would you ever want (for example) to double it?
Numeric Data Types
Numeric data is again divided into two groupings:
- Integers (whole numbers) e.g. 1, 0, -12
- Real numbers (numbers with decimal points) e.g. 1.4, -12.36, 0.0
Each grouping has several data types, depending on the range of values to be stored. In general, the larger the numbers to be stored, the more memory is needed for the variable. We try to use the smallest data type which will hold our expected range of values.
Integer Data Types
Integer Data Type | Range of Values |
---|---|
Byte |
0 through to 255 (positive values only) |
Short |
-32,768 through 32,767 |
Integer |
-2,147,483,648 through to 2,147,483,647 |
Long |
-9,223,372,036,854,775,808 through to 9,223,372,036,854,775,807 } |