How to Pass & Return Unsigned Integers to DLLs from VBLast reviewed: June 21, 1995Article ID: Q112673 |
The information in this article applies to:
- Standard and Professional Editions of Microsoft Visual Basic for Windows, versions 1.0, 2.0, and 3.0
SUMMARYVisual Basic supports signed integers, not unsigned integers. Therefore, the valid range of values, for an integer variable, is from -32767 to +32767. The C language supports unsigned integers, which have a range from 0 to 65536. To pass a value within the range 32767 to 65536, you need to do a conversion in code to see the correct results. This article shows you how.
MORE INFORMATIONVisual Basic stores its integer variables in an 8-bit data field, as does C. Visual Basic uses signed integers only, so it reserves one of the bits as a sign bit. In C, you have the choice of an unsigned integer (the variable ranges from 0 to 65536) or a signed integer (the variable ranges from -32767 to +32767 as do Visual Basic integer variables).
Step-by-Step ExampleFollow a process similar to the following to pass a value greater than 32767 as an integer from Visual Basic to a dynamic link library (DLL) that is expecting an unsigned integer or to return an integer value that is outside the range of valid Visual Basic integers:
|
Additional reference words: 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |