Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Passing an array to a DLL procedure

hitesh_kapadiahitesh_kapadia Member Posts: 6
Hello,

I am creating a DLL object in which I am creating a function which does some manipulation on the array passed to it. I am calling the function from another VB EXE project. The type of the array in the calling file is Variant(). When the function is called, it is giving an error 'Type Mismatch'. How do pass an array to the function? Please help me.

Thanks in advance.
Hitesh

Comments

  • HaroldDavisHaroldDavis Member Posts: 7
    : Hello,
    :
    : I am creating a DLL object in which I am creating a function which does some manipulation on the array passed to it. I am calling the function from another VB EXE project. The type of the array in the calling file is Variant(). When the function is called, it is giving an error 'Type Mismatch'. How do pass an array to the function? Please help me.
    :
    : Thanks in advance.
    : Hitesh
    :
    Hi Hitesh I hope this works for you.

    'First declare a variant to store the information in.
    Dim testvar2 As Variant
    'This represents variant array that you want to proccess
    Dim testvar1(3) As Variant
    ' Pass the Array that you want to proccess to the function
    ' Now the array that the function returns will be stored in the secound variable that
    'we created
    testvar2 = testfunc(testvar1)

    For I = 65 To UBound(testvar1)
    Debug.Print testvar1(I)
    Next

    'This is the function
    Public Function testfunc(ByVal testvar As Variant) As Variant

    Dim I As Integer

    For I = 1 To 3

    testvar(I) = Chr(I + 64)

    Next
    testfunc = testvar

    End Function

    Harold L. Davis



Sign In or Register to comment.