PDA

Click to See Complete Forum and Search --> : Passing string parameters out


ziozio
Mar 5th, 2001, 03:31 AM
I have a query regarding the passing and returning of string parameters from VB to exposed function in dll written on VC.

Say in the given scenario below,
In VB bas module:
Declare function encode_str lib "encoder.dll" (ByVal strInput As String,
ByRef strOutput As String,ByRef strOuputLen As Long) As Long

In VC:
long encode_str(LPSTR strInput,LPSTR *strOutput,long *strOutputLen)

In VB form:
Dim strInput,strOutput As String
Dim strOutputLen As Long
Dim retval As Long

strOutput = String(256,vbNullChar)

retval = encode_str(strInput,strOutput,strOutputLen)
MsgBox strOutput



The above code seems to work once, but on further calls to "encode_str", the call fails to generate any strOutput result to be passed back to the VB form.

Anyone has any idea or suggestions? Thanks.

Bill Crawley
Mar 6th, 2001, 03:59 AM
If it's not passing anything back, the fault must lie in the DLL.

ziozio
Mar 6th, 2001, 07:45 PM
Lets say I've put the code in the VB form as a click routine of a button. When the button is pressed the first time, strOutput is assigned a correct result. The next time the button is pressed, strOutput is not assigned any value.
Hence I don't think the problem lies in the dll.

Help...anyone??