Depends on what you you want to do with them. As you have such a limited range of string possabilities you could change your array definition in VBA from "Dim MyVarArr(0 To 3) As String" to "Dim MyVarArr(0 To 3) As String * 3" This will be faster in VBA as it does need to use the OLEautomation engine when you load the array. You would the change your DLL function declare in VBA to "Declare Function ProcStrArry Lib "C:\PBWin90\MySamples\MySample1.dll" (ByRef x() as string * 3)" so actually passing the address of the array descriptor.
The PB DLL would have code including the following
Code:
#INCLUDE "VBAPI32.inc" FUNCTION ProcStrArry ALIAS "ProcStrArry" (BYREF x DWORD) EXPORT AS STRING ' x is now the address of the array descriptor local MyArrayAddress as dword MyArrayAddress = vbArrayFirstElem(x) REDIM MyStringArray(vbArrayUBound(x, 1) as STRING * 6 at MyArrayAddress 'Documentation is sketchy so dimemsion might be 0 'STRING * 6 as should be UNICODE so must build own strings for comparisons if that is what you want 'so xc would be CHR$(00) & "x" & CHR$(00) & "c" & CHR$(00) & CHR$(00) 'which would only be done once at the start of the call or as GLOBALS on the DLL load
John
Leave a comment: