
Welcome in the new club of the dinosaurs users of VB6 !!!
Since several years, i try to passing all style of variables between PB and VB.
It's not simple for KCC, because VB not managing his variables like C and PB

He use BSTR, UNICODE ans SAFEARRAY

KCC have not big knowledge.. before he was helped by his MASTER...but now...his MASTER is tired to help KCC

Perhaps he don't like whirligig.....and KCC is the king for turned round..

But i thanks him when even, for all his help since several month....

So, perhaps a day ...a member need to do this, and be happy to find this tips, and not eat all his fingers to the bone

..........................................................................
.............................. THE STRINGS ..........................
..........................................................................
Passing a VB6 string by reference (Method allocate string by VB)
VB6 code
Code: Select all
Private Declare Sub GetMessage Lib "Fonctions.dll" (ByRef Chaine As String)
Private Sub Form_Load()
Test
End Sub
Sub Test()
ChDrive (Left(App.Path, 1))
ChDir App.Path
Dim Chaine As String
Chaine = String(255, vbNullChar)
GetMessage Chaine
MsgBox "Longueur de la chaine = " + Str(Len(Chaine)) + Chr(13) + Chaine
End Sub
Code: Select all
ProcedureDLL GetMessage(*chaine)
a$ = "Hello World !"
CopyMemory(@a$, PeekL(*chaine), Len(a$))
EndProcedure
VB6 code
Code: Select all
Private Declare Sub GetMessage Lib "Fonctions.dll" (ByVal Chaine As String)
Private Sub Form_Load()
Test
End Sub
Sub Test()
ChDrive (Left(App.Path, 1))
ChDir App.Path
Dim Chaine As String
Chaine = String(255, vbNullChar)
GetMessage Chaine
MsgBox "Longueur de la chaine = " + Str(Len(Chaine)) + Chr(13) + Chaine
End Sub
Code: Select all
ProcedureDLL GetMessage(*chaine)
a$ = "Hello World !"
CopyMemory(@a$, *chaine, Len(a$))
EndProcedure