MS Access 2010 VBA tutorial- Variable and Data type


VBA Variable and Data type

In building a program or software by using a programming language, it is common that some data are needed to store temporarily in computer memory for faster operations.
-Variable: A variable is referred to the location of memory to store a value.
-Data type:
  A data type can be said as a type of variable. The most commonly used data types in VBA are:  

 Byte: Stores positive values ranging from 0 to 255. This type will use 1 byte of memory size.
Integer:
Stores both negative and positive non-decimal values ranging from -32,768 to 32,767. This type will use 2 bytes of memory size.

Long: Stores both negative and positive non-decimal values ranging from -2,147,483,648 to 2,147,483,647. It uses 4 bytes of memory size.

Single:
Stores both negative and positive decimal values ranging from -3.402823E38 to -1.401298E-45 for negative values and 1.401298E-45 to 3.402823E38 for positive values. The long type uses 4 bytes of memory size.

Double: Stores both negative and positive decimal values ranging from -1.79769313486231E308 to -4.94065645841247E-324 for negative values and  4.94065645841247E-324 to 1.79769313486232E308 for positive values. It uses 8 bytes of memory size.

Date:
Stores date/time values. It uses 8 bytes of memory size. Boolean: Stores logical values—true or false. This type consumes 2 bytes of memory size.

Currency:
Stores currency values ranging from -922,337,203,685,477.5808 to 922,337,203,685,477.5807. It uses 8 bytes of memory size.

Variant:
Stores any values. It uses 16 bytes or more than this of memory size. String: Stores text values. Its use of memory depends on the length of text to store.


Comments





This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.