6.1.2.3 Conversion Module
Note
This section describes the implementation of MS-VBAL §6.1.2.3 Conversion Module.
The Conversion module is represented in the SDK by the interface
IStdConversionModule.
The Conversion module's declarations follow MS-VBAL's own Function Declaration blocks (MS-VBAL §6.1.2.3),
declaration by declaration, including their return types and their Optional parameters.
An object argument
A function that reads the value of its argument reads an object's simple data value (MS-VBAL §5.5.1.2.13):
what its default member returns, called with no arguments. That is every function of the module but CVar, which
returns its argument, object or not. As in MS-VBA (recorded in Excel), Nothing is error 91, an object with no default
member that can be called with no arguments is error 438, and an error its default member raises is the function's.
Int and Fix answer a Null read from an object with Null, as they answer Null; Hex, Oct and Str raise
error 94 for it, as MS-VBA does, although they answer a Null argument with Null. The Math module reads its
arguments the same way (RD-VBAL §6.1.2.10 Math).
👉 A default member that returns an object stands for that object's simple data value in turn, as Let-coercing the object would make it. MS-VBA raises error 51 for it instead, an internal error, which RD-VBA does not raise for a specified input.
MS-VBA refuses some of these at compile time: a Nothing literal ("Invalid use of object"), an object whose default
member takes an argument, such as a Collection ("Argument not optional"), and, given to CInt, an object whose
default member is declared As Object ("Type mismatch") - which Abs takes, and raises error 51 for at run time.
Error of a number that is no run-time error is "Application-defined or object-defined error", without the period
that ends the specification's sentence (MS-VBA, recorded in Excel).
6.1.2.3.1 Public Functions
Note
This section describes the implementation of MS-VBAL §6.1.2.3.1 Public Functions.
| § | Member | Notes |
|---|---|---|
| 6.1.2.3.1.1 | CBool | |
| 6.1.2.3.1.2 | CByte | |
| 6.1.2.3.1.3 | CCur | |
| 6.1.2.3.1.4 | CDate / CVDate | |
| 6.1.2.3.1.5 | CDbl | |
| 6.1.2.3.1.6 | CDec | |
| 6.1.2.3.1.7 | CInt | |
| 6.1.2.3.1.8 | CLng | |
| 6.1.2.3.1.9 | CLngLng | |
| 6.1.2.3.1.10 | CLngPtr | See §6.1.2.3.1.10. |
| 6.1.2.3.1.11 | CSng | |
| 6.1.2.3.1.12 | CStr | A number or a date is written in the regional settings of the session's environment, as let-coercion writes it (RD-VBAL §5.5.1.2.4). The error code of Error n is a whole number, written the same in any culture. A String is copied, every byte of its data. |
| 6.1.2.3.1.13 | CVar | |
| 6.1.2.3.1.14 | CVErr | |
| 6.1.2.3.1.15 | Error / Error$ | |
| 6.1.2.3.1.16 | Fix | 🎯 Declared As Variant; MS-VBA types a call of a number as the number's declared type, and so does RD-VBA: Fix(n) of an Integer is an Integer, and Fix(n) * 7000 overflows (error 6) where a Variant product would widen to a Long (recorded in Excel). RDC11018 warns where that shows. A call given any other type is a Variant. |
| 6.1.2.3.1.17 | Hex / Hex$ | 🎯 A negative number is written in the width of its type, as MS-VBA writes it, where the specification picks the width by the value: an Integer and a Boolean in 16 bits (Hex$(CInt(-32768)) is 8000), a Long in 32 (Hex$(CLng(-7)) is FFFFFFF9), a LongLong in 64, a LongPtr in its own. Any other type is Let-coerced to a LongLong and written in 64 bits: Hex$(-7.5) is FFFFFFFFFFFFFFF8, and Hex$(4294967296#) is 100000000, with no overflow. A Variant is written as what it holds. Recorded in 64-bit Excel; on a 32-bit host, which has no LongLong, any other type is Let-coerced to a Long, as the specification has it (not verified). |
| 6.1.2.3.1.18 | Int | 🎯 Typed as Fix is: a call of a number is of the number's declared type, as MS-VBA types it (RDC11018). |
| 6.1.2.3.1.19 | Oct / Oct$ | As Hex: Oct$(CLng(-7)) is 37777777771. |
| 6.1.2.3.1.20 | Str / Str$ | A number is written with . as the decimal separator, in any culture. A date is "the result of Let-coercing Number to String", in the regional settings of the session's environment, as CStr writes it. |
| 6.1.2.3.1.21 | Val |
6.1.2.3.1.10 CLngPtr
Note
This section describes the implementation of MS-VBAL §6.1.2.3.1.10 CLngPtr.
CLngPtr needs the one thing a standard-library declaration cannot state: its LongPtr return type depends on the
pointer width. LongPtr is a different type in each pointer width
(RD-VBAL §2.4.1 Intrinsic Types).
The pointer width belongs to the environment, and is passed to StdLibSymbolProvider (RD-VBAL §6.0.1 Symbol Injection).
⏮️ RD-VBAL §6.1.2.2 Constants Module | ⏭️ RD-VBAL §6.1.2.4 DateTime Module