| Start | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Option Explicit It is deemed best practice to always use Setting Require Variable Declaration within the VBE's Tools ► Options ► Editor property page will put the Option Explicit statement at the top of each newly created code sheet. This will avoid silly coding mistakes like misspellings as well as influencing you to use the correct variable type in the variable declaration. (Some more examples are given at ALWAYS Use "Option Explicit" (opens new window).) |
||||||||||||||||
| Option Base {0 | 1}
By default (and thus if no Option Base is specified), the Base is 0. Which means that the first element of any array declared in the module has an index of 0. If Example in Base 0 :Same Example with Base 1The second example generated a Subscript out of range (Error 9) (opens new window) at the first loop stage because an attempt to access the index 0 of the array was made, and this index doesn't exists as the module is declared with The correct code with Base 1 is :It should be noted that the Split function (opens new window) always creates an array with a zero-based element index regardless of any
In Excel, the Likewise, in ADO, the One recommended 'best practice' is to always use the LBound (opens new window) and UBound (opens new window) functions to determine the extents of an array. The |
||||||||||||||||
Option Compare {Binary | Text | Database} Option Compare BinaryBinary comparison makes all checks for string equality within a module/class case sensitive. Technically, with this option, string comparisons are performed using sort order of the binary representations of each character. A < B < E < Z < a < b < e < z If no Option Compare is specified in a module, Binary is used by default. Option Compare TextOption Compare Text makes all string comparisons within a module/class use a case insensitive comparison. (A | a) < (B | b) < (Z | z) Option Compare DatabaseOption Compare Database is only available within MS Access. It sets the module/class to use the current database settings to determine whether to use Text or Binary mode. Note: The use of this setting is discouraged unless the module is used for writing custom Access UDFs (User defined functions) that should treat text comparisons in the same manner as SQL queries in that database. Syntax
Parameters
RemarksIt is much easier to control the boundaries of arrays by declaring the boundaries explicitly rather than letting the compiler fall back on an |
Read Article
https://develop.horje.com/learn/1434/reference