Maybe this will help, here is what I had to do:
PB DLL Code:
Code: Select all
ProcedureDLL Get_2_Stuff()
Z_String_01 = "Some Fun Now."
ProcedureReturn @Z_String_01
EndProcedure
For the VBA portion (in Excel):
Code: Select all
Public Declare Function Get_2_Stuff Lib "Quotes_3_Lib01.dll" () As Long
Public Declare Function LStrCpy Lib "kernel32.dll" Alias "lstrcpy" (ByVal MyString As String, ByVal MyLong As Long) As Long
Public Target_String 'defined as variant
Public Tmp_String As String * 99
Target_String = Space(99) 'adjust as necessary
Z_String_ptr = Get_2_Stuff()
Tmp_out = LStrCpy(Tmp_String, Z_String_ptr)
Z_String_Len = Len(Trim(Tmp_String))
Target_String = Left(Trim(Tmp_String), Z_String_Len - 1)
What I have found out (through this forum) is that PB will only return a long from a procedure.
Or more correctly, I have a pointer to be returned.
So what is returned is a pointer to the string.
This was originally compiled under 3.94 of PB and Excel 2000.
Still compiles and works under Excel 2003.
Hope this helps!
Harry0