Data Types

 

From: http://www.functionx.com/vbaccess/Lesson03b.htm

 

Byte

 

 

If you are planning to use a numeric value in your program, you have a choice from different kinds of numbers that Visual Basic can recognize.  You can use the Byte data type for a variable that would hold a natural number that ranges from 0 to 255.

 

 

Integer

 

 

An integer is a natural number. To declare a variable that would hold a number that ranges from -32768 to 32767, use the Integer data type. The integer type should always be used when counting things such as books in a library or students in a school;

 

Long

 

 

A long integer is a number that can be used for a field or variable involving greater numbers than integers. To declare a variable that would hold such a large number like population of countries

 

Single

 

 

In computer programming, a decimal number is one that represents a fraction. Examples are 1.85 or 426.88. If you plan to use a variable that would that type of number but precision is not your main concern, declare it using the Single data type. Here is an example:

Private Sub Form_Load()
    Dim Distance As Single
End Sub

 

Double

 

 

If you want to use a decimal number that requires a good deal of precision, declare a variable using the Double data type.

 

In most circumstances, it is preferable to use Double instead of Single when declaring a variable that would hold a decimal number. Although the Double takes more memory spaces (computer memory is not expensive anymore(!)), it provides more precision.

 

Currency

 

 

The Currency data type is used to deal with monetary values. Here is an example of declaring it:

Private Sub Form_Load()
    Dim StartingSalary As Currency
End Sub

 

Date

 

 

In Visual Basic, a Date data type is used to specify a date or time value. Therefore, to declare either a date or a time variables, use the Date data type

 

Data Type

Prefix

Example

Boolean

bln

blnFound

Byte

byt

bytTracks

Date/Time

dtm

dteStartOfShift

Double

dbl

dblDistance

Error

err

errCantOpen

Integer

int

intNbrOfStudents

Long

lng

lngPopulation

Object

obj

objConnection

Single

sng

sngAge

String

str

strCountryName

Currency

cur

curHourlySalary

Variant

var

varFullName