How do I pass an array to a vb DLL  
Author Message
pcking999





PostPosted: Wed Sep 21 01:51:03 CDT 2005 Top

Exchange Servers >> How do I pass an array to a vb DLL

Howdy
Having a good time trying to use a vbDLL in FoxPro. I can run the dll and
set string, single and integers but can not pass an array. I saw the
conarray() property but it doesnt seem to help. Here is my Fox code:

PUBLIC otest
*SET STEP ON
otest = CREATEOBJECT("pmcmodshape.clspmcmodshape")
otest.lSingle = 1.00
otest.sString = "hi karen"
otest.iInteger = 1
COMARRAY(otest,10)
DIMENSION ArrayName[5]
ArrayName[1] = "Dan1"
ArrayName[2] = "Dan2"
ArrayName[3] = "Dan3"
ArrayName[4] = "Dan4"
ArrayName[5] = "Dan5"
SET sTEP ON


otest.gsubdoit()

=MESSAGEBOX("lSingle=" + ALLTRIM(STR(otest.lsingle, 2)))
=MESSAGEBOX("sString=" + ALLTRIM(otest.sstring))
=MESSAGEBOX(otest.iInteger, 0, "Integer")


RELEASE otest

Here is the VB Poperty that receives the Array
Public Property Let vArray(ByRef newvalue() As String)
Dim icount As Integer
Dim aArray(5) As Variant
Dim iSubscript As Integer

iSubscript = UBound(newvalue) - 1
For icount = 0 To UBound(newvalue) - 1

aArray(icount) = newvalue(iSubscript)
iSubscript = iSubscript - 1
Next
aNewArray = aArray

End Property

Any help would be appreciated

Exchange Server12  
 
 
Eric





PostPosted: Wed Sep 21 01:51:03 CDT 2005 Top

Exchange Servers >> How do I pass an array to a vb DLL Perhaps the following article can help you:
ArrayCom.exe Passing Array To COM DLL by Reference
http://support.microsoft.com/default.aspx?scid=kb;en-us;188255
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts
VFP MVP



> Howdy
> Having a good time trying to use a vbDLL in FoxPro. I can run the dll and
> set string, single and integers but can not pass an array. I saw the
> conarray() property but it doesnt seem to help. Here is my Fox code:
>
> PUBLIC otest
> *SET STEP ON
> otest = CREATEOBJECT("pmcmodshape.clspmcmodshape")
> otest.lSingle = 1.00
> otest.sString = "hi karen"
> otest.iInteger = 1
> COMARRAY(otest,10)
> DIMENSION ArrayName[5]
> ArrayName[1] = "Dan1"
> ArrayName[2] = "Dan2"
> ArrayName[3] = "Dan3"
> ArrayName[4] = "Dan4"
> ArrayName[5] = "Dan5"
> SET sTEP ON

>
> otest.gsubdoit()
>
> =MESSAGEBOX("lSingle=" + ALLTRIM(STR(otest.lsingle, 2)))
> =MESSAGEBOX("sString=" + ALLTRIM(otest.sstring))
> =MESSAGEBOX(otest.iInteger, 0, "Integer")
>
>
> RELEASE otest
>
> Here is the VB Poperty that receives the Array
> Public Property Let vArray(ByRef newvalue() As String)
> Dim icount As Integer
> Dim aArray(5) As Variant
> Dim iSubscript As Integer
>
> iSubscript = UBound(newvalue) - 1
> For icount = 0 To UBound(newvalue) - 1
>
> aArray(icount) = newvalue(iSubscript)
> iSubscript = iSubscript - 1
> Next
> aNewArray = aArray
>
> End Property
>
> Any help would be appreciated


 
 
Dan





PostPosted: Wed Sep 21 12:22:05 CDT 2005 Top

Exchange Servers >> How do I pass an array to a vb DLL Thanks Eric!
To put this in another way what I had found out and what you have confirmed
with the example app ou pointed me to is that when working with Fox instead
of simply setting a property (that happens to be an array) equal to the value
(or array ) in my local program I pass the array to a method.
This is strange to me from a VB point of view I would set all desired
properties and call any methods desired. Suppose I have a need for the array
to be in place in my vb app but not a need to interact like I would do
through a method? Whatever. I fond the way around this is to create a method
that will simply be used by foxpro applications to pass the desired arrays to
my DLL and then within that method I will set my array properties as needed.
Makes it a joy to work with FoxPro and Im sure all FoxPro Programmers love
to work with VB apps too ;)

Thanks for the input



> Perhaps the following article can help you:
> ArrayCom.exe Passing Array To COM DLL by Reference
> http://support.microsoft.com/default.aspx?scid=kb;en-us;188255
> --
> Eric den Doop
> www.foxite.com - The Home Of The Visual FoxPro Experts
> VFP MVP
>


> > Howdy
> > Having a good time trying to use a vbDLL in FoxPro. I can run the dll and
> > set string, single and integers but can not pass an array. I saw the
> > conarray() property but it doesnt seem to help. Here is my Fox code:
> >
> > PUBLIC otest
> > *SET STEP ON
> > otest = CREATEOBJECT("pmcmodshape.clspmcmodshape")
> > otest.lSingle = 1.00
> > otest.sString = "hi karen"
> > otest.iInteger = 1
> > COMARRAY(otest,10)
> > DIMENSION ArrayName[5]
> > ArrayName[1] = "Dan1"
> > ArrayName[2] = "Dan2"
> > ArrayName[3] = "Dan3"
> > ArrayName[4] = "Dan4"
> > ArrayName[5] = "Dan5"
> > SET sTEP ON

> >
> > otest.gsubdoit()
> >
> > =MESSAGEBOX("lSingle=" + ALLTRIM(STR(otest.lsingle, 2)))
> > =MESSAGEBOX("sString=" + ALLTRIM(otest.sstring))
> > =MESSAGEBOX(otest.iInteger, 0, "Integer")
> >
> >
> > RELEASE otest
> >
> > Here is the VB Poperty that receives the Array
> > Public Property Let vArray(ByRef newvalue() As String)
> > Dim icount As Integer
> > Dim aArray(5) As Variant
> > Dim iSubscript As Integer
> >
> > iSubscript = UBound(newvalue) - 1
> > For icount = 0 To UBound(newvalue) - 1
> >
> > aArray(icount) = newvalue(iSubscript)
> > iSubscript = iSubscript - 1
> > Next
> > aNewArray = aArray
> >
> > End Property
> >
> > Any help would be appreciated
>
>
>