Visual Basic 2008 Programming: Business Applications with a Design Perspective
Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9
Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Appendix A Appendix B Appendix C Home
Last change: February 13 2016 18:48:19.

 Chapter in PDF

Table of Contents

Chapter 4: Data, Operations, and Built-In Functions
Last change: February 13 2016 18:47:36.

4.3     Numeric Data and Types

VB has different ways of storing and handling numbers, depending on the types you declare for them. Some data types can handle only numbers without decimal points; others can handle a wide range of numeric values, from a very small fraction to a huge value. In addition, some data types have a low precision. They can be accurate for only a few significant digits. Others have a high precision, capable of holding many significant digits. Some selected numeric data types used in VB are given in the following table.

Data Type

Size in Bytes

Value Range

Type Suffix for Variable
Type Suffix for Literal Constant
Byte 1 0 to 255 (None) (None)
SByte 1 -128 to 127    
Char 2 0 to 65535 (None) C
Boolean 2 True or False (None) (None)
Short 2 -32,768 to 32,767 (singed) (None) S
UShort 2 0 to 65,535 (unsigned)    
Integer 4 -2,147,483,648 to 2,147,483,647 (signed % I
UInteger 4 0 to 232-1 (unsigned)    
Long 8 -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (signed) & L
ULong 8 0 to 264-1 (unsigned)    
Single 4 1.401298E-45 to 3.402823E+38 (in magnitude) ! F
Double 8 4.94065645841247E-324 to 1.79769313486231E+308 (in magnitude) # R
Date 8 0:00:00 on January 1, 0001 through 11:59:59 PM on December 31, 9999   # (Enclose)
Decimal 16 79,228,162,514,264,337,593,543,950,335 (in magnitude; with 28 places to the right or left of the decimal) @ D

Notice the last two columns in the table. The Type Suffix for Variable column shows the character to append to a variable to indicate the data type in declaration. As noted previously, declaring data with type suffixes makes the code less readable. Do not use them in your own code. They are listed here for your reference in case you encounter them when reviewing someone else’s code. The Type Suffix for Literal Constant column shows the character to append to a literal to force or make explicit its data type. For example, to indicate that the number 12345 is of the Decimal type, you code:
Also note that to show a date literal, you must enclosed the constant with a pair of pound (#) signs, such as #12/31/2002#.

Last change: February 13 2016 18:47:34.
  1. Form (Class)-Level Declaration
  2. Procedure-Level Declaration
  3. Static Declaration
  4. Scope and Lifetime: A Recap
  5. Scope and Program Modularity
  6. Constant and Variable Naming Convention
  • 4.3 Numeric Data and Types
    1. Byte,SByte and Char Types
    2. Boolean Type
    3. Short, UShort, Integer, UInteger, Long, and ULong Types
    4. Single and Double Types
    5. Other Numeric Data Types
    6. Declaring Numeric Data Types
    7. The Object Data Type
    8. Strict Implicit Type Conversion
    9. The Assignment Statement
    10. Numeric Operations
    11. Data Type Conversions
    12. Computing Net Sale: An Application Example
    13. The Format Function
    14. <<PreviousNext>>