Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass variable back to VFP from VB dll 1

Status
Not open for further replies.

richrichrich

Programmer
Sep 9, 2004
13
US
I call a VB dll from VFP7 to do some process and expect to return some infomation or flag back to VFP application for further process.

Lets assume that the VFP program will continue if "xFlag" is true.

Please let me know how to do that? Thanks!

e.g.

oapp = CREATEOBJECT("VBdll.VBfunction")
oapp.test_info(str1,str2)

if xFlag

do A_process

else

do nothing

endif

 
Instead of this:

oapp.test_info(str1,str2)

Maybe you need this:

xFlag = oapp.test_info(str1,str2)

Jim Osieczonek
Delta Business Group, LLC
 
Thanks Jim!

This should do it for the xFlag. Is it possible to return other values, like a string or something?

Thanks!
 
In my experience, string data is the simplest and easiest to reliably send back and forth between platforms. Numeric information is one of the hardest to send/receive to another program written in another language since some languages have several numeric types which don't always match exactly with the capabilities of the other language.

I say that because I wrote many ASP pages reading from and writing to VFP object properties and it was hard to keep track of how VBScript read and wrote VFP property types. I finally decided to only send/receive string data. Yes, I had to do conversion on both sides, but I always knew exactly what data type was sitting there and how it would behave.

In the specific object you listed above, that dll will return only what it was designed to return. If you want your VFP code to handle it as a string, then you can have VFP convert the returned value to string type.
 
I believe the datatype coming back is consistent with the datatype in the VB application. In other words, if you are "returning" string data then the xFlag would be string data, etc...

You also have the option of converting the data to string data so you do not need to modify the VB app.

Example:

Assume the VB app returns a numeric.
xFlag = ALLTRIM(STR(oapp.test_info(str1,str2)))

OR

xFlag = oapp.test_info(str1,str2)
xFlag = ALLTRIM(STR(xFlag))

IF you are not sure what the data type is, try using the TYPE() function to determine this and handle accordingly.

? TYPE('xFlag')




Jim Osieczonek
Delta Business Group, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top