No announcement yet.

Passing a PB array to VB

  • 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:
    Function VB_IRR(MyArray() as Double) As Double
        VB_IRR = IRR(MyArray())
    End Sub
    The PB code would be something like:
    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
    Daniel Corbier
    uCalc Fast Math Parser
    uCalc Language Builder

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

    #INCLUDE ""
    #INCLUDE ""

    sub ProcessArray (ArrayHeader as DWORD) EXPORT

    DIM ArrayDim as LONG
    DIM ArrayAddress as DWORD


    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!


    John Kovacich

    John Kovacich
    Ivory Tower Software