Software Archive
Read-only legacy content
17061 Discussions

strings from VF to VB example

Intel_C_Intel
Employee
392 Views
Hi,

I'm a DVF 6.0 user. I got my version from the Network at my workplace. In order to keep the size of their network down, they left out all of the examples of how to use the program. I'm a new user (pretty much learning as I go). I understand how to pass strings from VB to VF but can't seem to figure out how to get a string from VF to VB. I was hoping that either an example would help me out or one of you guys could help me. I'm using code that came before me so the code is not the issue. Just coding the passing strings is all I need to know.

Thanks,
Matt
0 Kudos
5 Replies
Intel_C_Intel
Employee
392 Views
Is VB the calling program? If so pass the string from VB to VF, set the value in VF and when you return to VB, the string will be set to the new value. I don't think you can change the length of a string in VF, so you need to set the length in VB first and then VF can change it.
0 Kudos
Intel_C_Intel
Employee
392 Views
VB is calling a Fortran Sub on a DLL, Fortran is calculating and giving the values back to VB. I'm ok with passing a string from VB to VF (ByVal strDataIn as String w/ Reference call in Fortran DLL). But for some reason, the string I want from Fortran is not passing to VB. I'm using:

Declare Sub Pandora Lib "Pandora2.dll" (IDataIn As Long, DataIn As Single, ByVal CDataIn As String, DataOut As Single, ByVal CFilename As String, IErr As Long)
....
Call Pandora(flngDataIn(1), fsngDataInput(1), fstrDataIn, fsngDataOut(1), fstrFileName, lngErr)

Here's in the DLL:
!DEC$ ATTRIBUTES STDCALL,DLLEXPORT :: PANDORA
!DEC$ ATTRIBUTES ALIAS : "Pandora" :: PANDORA
!DEC$ ATTRIBUTES REFERENCE :: CDATAIN
SUBROUTINE PANDORA(IDATAIN,DATAIN,CDATAIN,DATAOUT,CFILENAME,IERR)

CFilename is the string I want from Fortran. Why is it not going to VB like I think it should?
0 Kudos
Intel_C_Intel
Employee
392 Views
You need to add CFILENAME to your reference statement:

!DEC$ ATTRIBUTES REFERENCE :: CDATAIN,CFILENAME
0 Kudos
Intel_C_Intel
Employee
392 Views
Forgot to mention that I'm getting a runtime Error 49...which is a Bad Dll calling convention. Maybe that's what's wrong. Haven't figured out how to correct that either. uuhhh...little help? and ty sd
0 Kudos
Intel_C_Intel
Employee
392 Views
I believe that fixing the reference will also fix the bad calling convention. I have gotten the bad calling convention before and I don't recall exactly what caused the problem, but the problem has to do with the parameters, either the number of parameters, parameter types or the string parameters missing in the reference statement.
0 Kudos
Reply