The information in this article applies to:
Advanced: Requires expert coding, interoperability, and multiuser skills. SUMMARYThere are situations in which calling functions from external dynamic-link libraries (dlls) returns a 2-byte unsigned integer. Visual Basic for Applications does not support this data type. So that Access can correctly evaluate this data type, you need to convert it from an unsigned integer to a Long Integer data type. MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to provide added
functionality or construct procedures to meet your specific needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.aspThe Integer data type has a range of -32,768 to 32,767. An unsigned integer has a range of 0 to 65,536. Access uses the most significant bit to set the sign of the value. Therefore, when a value exceeds 32,767, bit 16 is set to reflect a negative number. To evaluate an unsigned integer, you must manually adjust bit 16. There are two methods to convert to and from the unsigned integer type to the Long Integer data type. The first method uses basic arithmetic (65,536 is subtracted or added to the unsigned integer). The second uses bit-wise operators. The arithmetic method works as well as the bit-wise method; however, the arithmetic method may be more readable, while the bit-wise method may be faster when executed repetitively. Open a new module or a previously created module and enter the following code:
Examples of Using These FunctionsAn external dynamic-link library requires and returns an unsigned integer. The Declare statement looks like the following:
The Declare statement uses Integer data types because Access does not support unsigned integers. However, the external dynamic-link library returns an unsigned integer that must be converted; therefore, the code may appear as follows:
REFERENCESFor more information about converting code from earlier Microsoft Access versions, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type "Convert Code that calls a DLL" in the Office Assistant or the Answer Wizard, and then click Search to view the topic. Additional query words:
Keywords : kbprg kbdta |
Last Reviewed: July 7, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |