I must call C DLL with VB6.
C Code
short int decode(BOOL Mode, char* tete, char* adresse, char* status, char* nombre, char* datadecode);
My VB Code :
Private Declare Function decode Lib "VBdecode.dll" ( _
ByVal Mode As Long, _
ByVal tete As String, _
ByVal adresse As String, _
ByVal status As String, _
ByVal nombre As String, _
ByVal datadecode As String) As Long
Dim retour_lire As Long
Dim buffer(4) As Byte
Dim vbcData as string
Dim i As Integer
Dim chdecode As string
retour_lire = Byte_read(True, "4", "00", buffer, "16", vbcData)
For i = 1 To 10
chdecode = vbcData(i)
Next
MsgBox chdecode
but my VB6 code is not functional.
please any ideas, any proposals or corrections.
please help me, I count on you.
The comments are actually wrong. You are right. VB6 will convert
String
s (sent that way, anyway) aschar*
. If you were usingVarPtr()
or usingAs Any
, they would be right.Your problem is the return value. Either change
short int
on the C++ side toint
or changeAs Long
on the VB6 side toAs Integer
.So either:
or:
Not both :)!
It's worth noting, your sample code doesn't ever actually call
decode()
. So another issue, and this is just a guess, is that you're trying to change the contents of a string on the C++ side. You can make changes to the string, but you can't reallocate it. So you need to have it already sized (usingSpace$()
).