Announcement

Collapse

Maintenance

The forum could be offline for 30-60 minutes in the very near future for maintenance (said 3pm Pacific). I was behind on getting this notice. I do apologize.
See more
See less

Passing a PB array to VB

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Passing a PB array to VB

    The documentation explains several ways of passing an array from
    VB to PB. Now is there a way to pass an array from PB to VB.
    I want to pass the array as a function parameter? For instance,
    VB's function might look like this:
    Code:
    Function VB_IRR(MyArray() as Double) As Double
        VB_IRR = IRR(MyArray())
    End Sub
    The PB code would be something like:
    Code:
    Declare Sub VBIRR(MyArray()) As Double
    
    Dim MyArray(100) As Double
    Call Dword AddressOfVB_IRR Using VBIRR(MyArray()) To Result#
    From the help file, I see that VB uses a different type of
    array descriptor, so the above would likely not work. How can
    a PB array be passed? Is this something that's possible?

    Here's a different question. Within PB, can you pass an array
    as an argument of a function? I imagine you can, but the help
    doesn't point this out (at least not where I was looking).

    ------------------
    Daniel Corbier
    UCalc Fast Math Parser
    http://www.ucalc.com
    Daniel Corbier
    uCalc Fast Math Parser
    uCalc Language Builder
    sigpic

  • #2
    When I pass arrays to PB, I use the following PB code:

    #INCLUDE "win32api.inc"
    #INCLUDE "vbapi32.inc"

    sub ProcessArray (ArrayHeader as DWORD) EXPORT

    DIM ArrayDim as LONG
    DIM ArrayAddress as DWORD

    ArrayDim=vbArrayUBound(ArrayHeader,1)
    ArrayAddress=vbArrayFirstElem(ArrayHeader)

    DIM Array(ArrayDim) AT ArrayAddress

    end sub

    Maybe, if you establish your array up this way first, having VB call PB to pass
    the address of the array header, then perhaps you can simply modify the array and
    then call the VB routine (if you can do that), without passing the array
    to VB (this is like having the array as a global array).

    Or maybe it won't work and you'll just find new ways to GPF.

    Good Luck!

    ------------------
    Thanks,

    John Kovacich
    Thanks,

    John Kovacich
    Ivory Tower Software

    Comment

    Working...
    X