|
Intrinsic constants are ones that are automatically defined by Access or VBA. You can find a full list of these in the Access help file, under the Visual Basic Language Reference section.
For example, earlier in the chapter we used the VarType() function to determine the type of a variant. If you wanted to test a variant to see whether it contained a string you could do this:
If VarType(varAnyThing) = 8 Then
However, this has the immediate disadvantage in that you must know what the value 8 means. Luckily there is a set of intrinsic constants just for this purpose. Let's have another look at the table:
Value | Variant type | Constant |
---|---|---|
| Empty ( uninitialized ) | vbEmpty |
1 | Null (no valid data) | vbNull |
2 | Integer | vbInteger |
3 | Long Integer | vbLong |
4 | Single | vbSingle |
5 | Double | vbDouble |
6 | Currency | vbCurrency |
7 | Date | vbDate |
8 | String | vbString |
9 | Object | vbObject |
10 | Error value | vbError |
11 | Boolean | vbBoolean |
12 | Variant (only used with arrays of variants) | vbVariant |
13 | Data access object | vbDataObject |
14 | Decimal value | vbDecimal |
17 | Byte | vbByte |
36 | User Defined Type | vbUserDefinedType |
8192 | Array | vbArray |
Now our code becomes much more readable:
If VarType(varAnyThing) = vbString Then
You'll see plenty of uses of intrinsic and user-defined constants as we go through the book.
|