OFF2000: Conversions for C Data Types in Visual Basic for Application (210567)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q210567
Advanced: Requires expert coding, interoperability, and multiuser skills.

SUMMARY

This article describes some of the conversions between Visual Basic for Applications and C arguments.

MORE INFORMATION

The following are general data type conversions:

   hWnd            ByVal var As Long
   LPSTR           ByVal var As String
   hDC             ByVal var As Long
   WORD            ByVal var As Integer
   DWORD           ByVal var As Long
   INT             ByVal var As INT
   INT FAR *       intValue As Integer
   CHAR FAR *      ByVal var As String
   LONG            ByVal var As Long
   LONG FAR *      var As Long
   BYTE            ByVal var As Byte
   BOOL            ByVal var As Boolean
   UNSIGNED SHORT  ByVal var As Integer
   UNSIGNED CHAR   ByVal var As Integer - must convert with Asc(var)
   UNSIGNED LONG   ByVal var As Long
				
The following list shows how to define the C data type in a Visual Basic for Applications data type:
   BYTE, BOOL            Var As String * 1

   LPSTR, CHAR FAR *     Var As Long       - Use API lstrcpy() to get
                                             the string pointer.

   anything FAR *        Var As Long       - This does not give the correct
                                             data type but contains the
                                             correct number of bytes; you
                                             may have to convert.
				
The following list describes the differences returned from a function:
   LPSTR               Function As Long    - Use lstrcpy() to get the
                                             string from the pointer.
				

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbhowto kbProgramming KB210567