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.
Sometimes you'll run across numeric parameters that require an unsigned value. The general algorithm for supplying that value is to convert the value to its next highest data type, subtract the maximum value that the data type can carry, and then convert it back to the original data type.
The following table shows how to convert values from unsigned to signed, and vice versa, for the bit widths of values supported by VBA.
Was this article helpful?