Access™ 2007 VBA Programmer's Reference
by Teresa Hennig, Rob Cooper, Geoffrey Griffith, Armen Stein
14.4. Understanding C Parameters
Most APIs were written by C programmers, so most APIs are written specifically for the C language. Consequently, there are many APIs that are completely unusable by VBA because VBA does not support some of the data types required by those 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.
14.4.1. Signed and Unsigned Integers
First, the C language uses something that is unknown to VBA: unsigned numbers. VBA uses only signed numbers. An unsigned number is a positive number; that is, it does not have a sign. A signed number can be either positive or negative because of the sign. VBA does actually support one unsigned data type: Byte. For example, Figure 14-6 shows an 8-bit byte. 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 14.6. Figure 14-6
Sometimes you'll run across ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access