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

Last reviewed: June 8, 1997
Article ID: Q93141
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0

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 "padded"). 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 "C" 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.

REFERENCES

For more information about this topic, search for "Type Statement" using the Microsoft Access Help menu.


Additional query words: windows api data type
Keywords : kbprg PgmDecl PgmHowTo PgmOthr
Version : 1.0 1.1 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 8, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.