viernes, 29 de diciembre de 2017

Excel Macros Tutorial 1.4 | Types of Variables


to declare a variable, you have to do it like this:

dim Variable_Name as Type_of_Variable

"Dim" followed by a name for the variable, then "as" followed by the variable type. 

you can declare as many variables as you want. Instead of declaring each variable on its own line, you can declare more than one variable on the same line. To do this, use one Dim keyword and separate the names of variables with commas.

Some of the variable types are:
Integer
Will hold a number that ranges from -32768 to 32767

Instead of using As Integer, you can use the % type character.
Dim Tracks%


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


Boolean
Will hold a True or False value

String
A string is a character or a combination of characters that constitute text of any kind and almost any length. To declare a string variable, use the String data type.


There are many other variable types that we can go though in next posts.



No hay comentarios:

Publicar un comentario

Excel Macros Tutorial 1.4 | Types of Variables

to declare a variable, you have to do it like this: dim Variable_Name as Type_of_Variable "Dim" followed by a name for the va...