Boolean
A Boolean variable can hold a True/False value. Boolean variables (and properties) are used frequently in VBA programming to hold data that can be on/off, yes/no, and so on. When you declare a Boolean variable, it is automatically initialized to False.
- Read more about Boolean
- Log in or register to post comments
Variant
Variant is VBA’s most flexible data type as well as the default type. The Variant data type can hold almost any type of data, the exceptions being fixedlength strings and user-defined types. The downside is that Variant data requires more memory to store, and more computer power to process, than other data types.
- Read more about Variant
- Log in or register to post comments
User-Defined Types
A user-defined type (UDT) allows the programmer to define custom data elements that are specifically suited for the data at hand. A UDT can contain two or more elements, each element being a variable or array. UDTs are defined with the Type...End Type statement.
- Read more about User-Defined Types
- Log in or register to post comments
Nothing
There are situations where an object variable does not refer to any object: It refers to nothing, and VBA has the special keyword Nothing to represent this. An object variable contains Nothing when it has been declared but not yet initialized (has not been assigned an object reference).
Finally, you can (and should) explicitly set an object reference to Nothing when you are finished using the object
- Read more about Nothing
- Log in or register to post comments
With...End With
The With...End With construct cannot be called a control statement because it does not modify code execution. It does, however, provide a handy shorthand that simplifies writing code in certain situations.
- Read more about With...End With
- Log in or register to post comments
If...Then Statement
The If...Then statement, or If statement for short, is used in a program to execute a block of code if a specified logical condition is True. If condition is True, the statements in the block (indicated by block1) are executed. If condition is False, they are not executed.
- Read more about If...Then Statement
- Log in or register to post comments
The Select Case Statement
The Select Case statement lets your program make multiple choices based on the value of a single expression.
- Read more about The Select Case Statement
- Log in or register to post comments
Do...Loop Statement
The Do...Loop statement, or Do for short, is used to execute a block of statements repeatedly—in other words, to loop through the statements.
This statement comes in several variations that can meet essentially any program need.
- Read more about Do...Loop Statement
- 1 comment
- Log in or register to post comments
For...Next Statement
The For...Next statement repeats a block of code a specified number of times.
- Index is a variable that is used to count loop repetitions. It is usually declared to be type Integer.
- Start is an expression specifying the starting value of index.
- Stop is an expression specifying the ending value of index.
Optionally, For...Next can use an increment value other than 1.
- Read more about For...Next Statement
- Log in or register to post comments
Goto Statement
The Goto statement instructs program execution to go to the specified location in the code.
A label itself has no effect on program operation—it serves only as the target of a Goto.
- Read more about Goto Statement
- 3 comments
- Log in or register to post comments