Passing Arrays into VbScript from a VB dll 
Author Message
 Passing Arrays into VbScript from a VB dll

Hi,

This driving me crazy!!

I have a VB dll that contains

    Public Function A() As Integer()
        Dim myArray(0 to 1000)
        ....
        A=myArray
    End Function

Then an asp page which contains
    Dim aspArray()
    aspArray() = myArray()

I keep getting the error "Subscript out of range"

Can anyone help a beginner and show him the error of his ways.

Thanks

Paul Clements



Sat, 28 Dec 2002 03:00:00 GMT  
 Passing Arrays into VbScript from a VB dll
Try

Redim aspArray(ubound(myarray))

before you equate them.

steve


Quote:
> Hi,

> This driving me crazy!!

> I have a VB dll that contains

>     Public Function A() As Integer()
>         Dim myArray(0 to 1000)
>         ....
>         A=myArray
>     End Function

> Then an asp page which contains
>     Dim aspArray()
>     aspArray() = myArray()

> I keep getting the error "Subscript out of range"

> Can anyone help a beginner and show him the error of his ways.

> Thanks

> Paul Clements



Sat, 28 Dec 2002 03:00:00 GMT  
 Passing Arrays into VbScript from a VB dll

You can't assign an array to an existing Dim'd array, but you can assigned it to an individual
element of such an array to a simple variant.

In other words just do:

Dim aspArray

not

Dim aspArray()

--
Michael Harris
MVP Scripting


Hi,

This driving me crazy!!

I have a VB dll that contains

    Public Function A() As Integer()
        Dim myArray(0 to 1000)
        ....
        A=myArray
    End Function

Then an asp page which contains
    Dim aspArray()
    aspArray() = myArray()

I keep getting the error "Subscript out of range"

Can anyone help a beginner and show him the error of his ways.

Thanks

Paul Clements



Sat, 28 Dec 2002 03:00:00 GMT  
 Passing Arrays into VbScript from a VB dll
Hi Steve,

Thanks for the response, unfortunately I can't see how I can do waht you
suggest due to the fact that I'm passing the array back at the time I am
equating them or have I misunderstood you?

Regards

Paul

Quote:
> Try

> Redim aspArray(ubound(myarray))

> before you equate them.

> steve



> > Hi,

> > This driving me crazy!!

> > I have a VB dll that contains

> >     Public Function A() As Integer()
> >         Dim myArray(0 to 1000)
> >         ....
> >         A=myArray
> >     End Function

> > Then an asp page which contains
> >     Dim aspArray()
> >     aspArray() = myArray()

> > I keep getting the error "Subscript out of range"

> > Can anyone help a beginner and show him the error of his ways.

> > Thanks

> > Paul Clements



Sun, 29 Dec 2002 03:00:00 GMT  
 Passing Arrays into VbScript from a VB dll
Hi Michael,

Thanks for your reply its got me part of the way unfortunately now when I
try to reference the
array ie.
    for i=0 to ubound(aspArray)
        num = aspArray(i)
    Loop
I get a type mistmatch error

Now I presume its something to do with the fact that its a variant but I'm
lost to how to deal with them.

Regards

Paul


Quote:

> You can't assign an array to an existing Dim'd array, but you can assigned
it to an individual
> element of such an array to a simple variant.

> In other words just do:

> Dim aspArray

> not

> Dim aspArray()

> --
> Michael Harris
> MVP Scripting



> Hi,

> This driving me crazy!!

> I have a VB dll that contains

>     Public Function A() As Integer()
>         Dim myArray(0 to 1000)
>         ....
>         A=myArray
>     End Function

> Then an asp page which contains
>     Dim aspArray()
>     aspArray() = myArray()

> I keep getting the error "Subscript out of range"

> Can anyone help a beginner and show him the error of his ways.

> Thanks

> Paul Clements



Sun, 29 Dec 2002 03:00:00 GMT  
 Passing Arrays into VbScript from a VB dll

You need the COM method to return an array of variants of subtype integer, not an array of strongly
typed integers.  Script clients can't handle arrays of non-variants.

--
Michael Harris
MVP Scripting


Hi Michael,

Thanks for your reply its got me part of the way unfortunately now when I
try to reference the
array ie.
    for i=0 to ubound(aspArray)
        num = aspArray(i)
    Loop
I get a type mistmatch error

Now I presume its something to do with the fact that its a variant but I'm
lost to how to deal with them.

Regards

Paul


Quote:

> You can't assign an array to an existing Dim'd array, but you can assigned
it to an individual
> element of such an array to a simple variant.

> In other words just do:

> Dim aspArray

> not

> Dim aspArray()

> --
> Michael Harris
> MVP Scripting



> Hi,

> This driving me crazy!!

> I have a VB dll that contains

>     Public Function A() As Integer()
>         Dim myArray(0 to 1000)
>         ....
>         A=myArray
>     End Function

> Then an asp page which contains
>     Dim aspArray()
>     aspArray() = myArray()

> I keep getting the error "Subscript out of range"

> Can anyone help a beginner and show him the error of his ways.

> Thanks

> Paul Clements



Sun, 29 Dec 2002 03:00:00 GMT  
 Passing Arrays into VbScript from a VB dll
Hi Michael,

Thanks for the information

Paul


Quote:

> You need the COM method to return an array of variants of subtype integer,

not an array of strongly
Quote:
> typed integers.  Script clients can't handle arrays of non-variants.

> --
> Michael Harris
> MVP Scripting



> Hi Michael,

> Thanks for your reply its got me part of the way unfortunately now when I
> try to reference the
> array ie.
>     for i=0 to ubound(aspArray)
>         num = aspArray(i)
>     Loop
> I get a type mistmatch error

> Now I presume its something to do with the fact that its a variant but I'm
> lost to how to deal with them.

> Regards

> Paul



> > You can't assign an array to an existing Dim'd array, but you can
assigned
> it to an individual
> > element of such an array to a simple variant.

> > In other words just do:

> > Dim aspArray

> > not

> > Dim aspArray()

> > --
> > Michael Harris
> > MVP Scripting



> > Hi,

> > This driving me crazy!!

> > I have a VB dll that contains

> >     Public Function A() As Integer()
> >         Dim myArray(0 to 1000)
> >         ....
> >         A=myArray
> >     End Function

> > Then an asp page which contains
> >     Dim aspArray()
> >     aspArray() = myArray()

> > I keep getting the error "Subscript out of range"

> > Can anyone help a beginner and show him the error of his ways.

> > Thanks

> > Paul Clements



Mon, 30 Dec 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Passing arrays from VBScript to VB DLL

2. Passing Arrays to a VB 5.0 SP3 DLL using VBScript control

3. Passing arrays from a VB dll into a VBScript

4. passing arrays to vb dll

5. Passing array from VB to DLL and returning array

6. Passing array from ASP (VBScript) to DLL and back

7. passing array from VBScript to Visual Basic ActiveX DLL

8. Help: Pass object to VB DLL in VBScript

9. passing arrays from vb dll to vb form

10. how to pass the array from vb to vbscript

11. PB/DLL passing multidimensional VB arrays by pointers

12. Passing Array of data from DLL to VB

 

 
Powered by phpBB® Forum Software