Types of Variables

Visual Basic recognizes the following five categories of variables :

  • numeric
  • string
  • boolean
  • date
  • object

The two major variable categories are numeric and string. Numeric variables store numbers, and string variables store text. Object variables can store any type of data.Why bother to specify the type if one type suits all? On the surface, using object variables might seem like a good idea, but they have their disadvantages. Integer variables are optimized for storing integers, and date variables are optimized for storing dates. Before VB can use an object variable, it must determine its type and perform the necessary conversions. If the variable is declared with a specific type, these conversions are not necessary.
 
Text is stored in string variables, but numbers can be stored in many formats, depending on the size of the number and its precision. That’s why there are many types of numeric variables.