Microsoft KB Archive/93141

= ACC: How to Pass a Single Byte of Data to Windows API Calls =

Article ID: 93141

Article Last Modified on 5/9/2003

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition

-



This article was previously published under Q93141



SUMMARY
Advanced: Requires expert coding, interoperability, and multiuser skills.

Microsoft Access versions 1.x and 2.0 do not have a single-byte data type. To pass a byte to an external function, such as a Windows application programming interface (API) function or a dynamic-link library (DLL) in Microsoft Access versions 1.x and 2.0, you should declare the byte as an integer.

If you need to pass a single byte of information in a data type, such as the RGBQUAD structure, you should pass the data structure as a string type.

NOTE: Microsoft Access for Windows 95 version 7.0 now has a Byte data type.



MORE INFORMATION
The Intel chip supports only a full word on the stack. You cannot put just 8 bits on the stack; you must use the full 16 bits. If you attempt to pass only 8 bits, you will end up passing 16 bits (your 8 bits of data plus an additional 8 bits that will be &quot;padded&quot;). This is a limitation of the processor, not of Microsoft Access.

To pass a single byte of data in a structure such as the RGBQUAD, use a fixed-length string of 1. For example, suppose you want to pass a single byte in the &quot;C&quot; RGBQUAD data structure, which looks like this:

  typedef struct tagRGBQUAD{ BYTE  rgbBlue; BYTE  rgbGreen; BYTE  rgbRed; BYTE  rgbReserve; } RGBQUAD

You can redefine this structure with Access Basic as:

  Type RGBQUAD rgbBlue As String * 1 rgbGreen As String * 1 rgbRed As String * 1 rgbReserve As String * 1 End Type

Dim RGB As RGBQUAD

RGB.rgbBlue = Chr$(10) RGB.rgbRed = Chr$(14) RGB.rgbGreen = Chr$(15)

  NOTE: In the above example, Blue=10, Red=14, and Green=15.

