13.4. Understanding C Parameters
Most APIs were written by C programmers, so most APIs are written specifically for the C language. Because of this, there are many APIs that are completely unusable by VBA, because VBA does not support some of the data types required by these APIs. Of those APIs that are accessible to VBA, most require consideration with regard to the data types used. Use a wrong data type and your computer will quickly let you know all about it.
The following sections describe the C data types often specified for API parameters, the VBA data types that should be used with them, the recommended calling conventions, and, where applicable, the technique that converts signed integer values from unsigned integer values and vice versa.
13.4.1. Signed and Unsigned Integers
The first thing to note at this point is that the C language uses something that is unknown to VBA: signed numbers. VBA only uses unsigned numbers. For example, Figure 13-6 shows an 8-bit byte. Notice that having a binary 1 in the most significant bit (the eighth bit) signifies that the number contained within the byte is a negative number. A 0 in the same position indicates that the number is positive.
Figure 13.6. Figure 13-6
Although the total number of values that a single byte can hold (employing both positive and negative number ranges) increases, the number of possible positive numbers decreases ...
Get Access 2003 VBA Programmer's Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.