Connecting Tech Pros Worldwide Forums | Help | Site Map

1-based index array issue

John Dolan
Guest
 
Posts: n/a
#1: Nov 20 '05
Hi all, I need some help here.

I have an ActiveX object that requires me to pass in an array that is
1-based (as opposed to the normal 0-based index). Unfortunately the author
of the ActiveX defines a 1-based array (to be passed to it) ByRef. So as far
as I can tell I need to pass it a 1-based array. I'm new to .NET but I've
done some homework here and I know that the VB 6.0 "Option Base 1" and like
alternatives are no longer supported. I have also gone back to the developer
of the ActiveX object and asked them to write the #$%! object so I could
pass in a 0-based array, but that has gotten me nowhere.

Any tips, hints, advice or solutions will be greatly appreciated. I've
attempted to add an extra row/column to the arrays and a properly bounded
0-based array with no success. Here is some simplified sample code the
author provided so you have an idea what I'm trying to do.


Dim aryHdrParamList(1 To 4)
Dim aryLineParamMatrix(1 To 30, 1 To 5)

aryHdrParamList(1) = "1"
aryHdrParamList(2) = "1"
aryHdrParamList(3) = "2GXCL0000"
aryHdrParamList(4) = "NONE"

aryLineParamMatrix(1, 1) = "0532"
aryLineParamMatrix(1, 2) = Empty

Set objMethod = CreateObject("Server.Service")
Call objMethod.GetInfo(aryHdrParamList, aryLineParamMatrix)

MsgBox aryHdrParamList(1) & " " & aryHdrParamList(2) & " " &
aryHdrParamList(3)
MsgBox aryLineParamMatrix(1, 1) & aryLineParamMatrix(1, 4) & " " &
aryLineParamMatrix(1, 5)


Ray Cassick \(Home\)
Guest
 
Posts: n/a
#2: Nov 20 '05

re: 1-based index array issue


I don't see why the indexing would matter between the two objects. If you
create an array in VB.NET that is 0 bassed, say with elements starting at 0
to 4 (5 elements) and then pass it to an object that takes the array, that
object woul djust address them using 1 as the first element.

"John Dolan" <john@coole.com> wrote in message
news:O8luJKy9DHA.1636@TK2MSFTNGP12.phx.gbl...[color=blue]
> Hi all, I need some help here.
>
> I have an ActiveX object that requires me to pass in an array that is
> 1-based (as opposed to the normal 0-based index). Unfortunately the author
> of the ActiveX defines a 1-based array (to be passed to it) ByRef. So as[/color]
far[color=blue]
> as I can tell I need to pass it a 1-based array. I'm new to .NET but I've
> done some homework here and I know that the VB 6.0 "Option Base 1" and[/color]
like[color=blue]
> alternatives are no longer supported. I have also gone back to the[/color]
developer[color=blue]
> of the ActiveX object and asked them to write the #$%! object so I could
> pass in a 0-based array, but that has gotten me nowhere.
>
> Any tips, hints, advice or solutions will be greatly appreciated. I've
> attempted to add an extra row/column to the arrays and a properly bounded
> 0-based array with no success. Here is some simplified sample code the
> author provided so you have an idea what I'm trying to do.
>
>
> Dim aryHdrParamList(1 To 4)
> Dim aryLineParamMatrix(1 To 30, 1 To 5)
>
> aryHdrParamList(1) = "1"
> aryHdrParamList(2) = "1"
> aryHdrParamList(3) = "2GXCL0000"
> aryHdrParamList(4) = "NONE"
>
> aryLineParamMatrix(1, 1) = "0532"
> aryLineParamMatrix(1, 2) = Empty
>
> Set objMethod = CreateObject("Server.Service")
> Call objMethod.GetInfo(aryHdrParamList, aryLineParamMatrix)
>
> MsgBox aryHdrParamList(1) & " " & aryHdrParamList(2) & " " &
> aryHdrParamList(3)
> MsgBox aryLineParamMatrix(1, 1) & aryLineParamMatrix(1, 4) & " " &
> aryLineParamMatrix(1, 5)
>
>[/color]


Guest
 
Posts: n/a
#3: Nov 20 '05

re: 1-based index array issue


I thought this as well, but since, and this is my assumption, the arrays are
passed ByRef its not possible. The one thing I do know for sure is that if I
pass it a zero-based array I will get an "array out of bounds" error, but if
I pass it as one-based it works fine.

For example the code below works with:
Dim aryHdrParamList(1 To 4)

But fails with either:
Dim aryHdrParamList(4)

Or:
Dim aryHdrParamList(5) -- where I would leave aryHdrParamList(0) empty.


"Ray Cassick (Home)" <rcassickNOSPAM@enterprocity.com> wrote in message
news:eLvfXI29DHA.2656@TK2MSFTNGP11.phx.gbl...[color=blue]
> I don't see why the indexing would matter between the two objects. If you
> create an array in VB.NET that is 0 bassed, say with elements starting at[/color]
0[color=blue]
> to 4 (5 elements) and then pass it to an object that takes the array, that
> object woul djust address them using 1 as the first element.
>
> "John Dolan" <john@coole.com> wrote in message
> news:O8luJKy9DHA.1636@TK2MSFTNGP12.phx.gbl...[color=green]
> > Hi all, I need some help here.
> >
> > I have an ActiveX object that requires me to pass in an array that is
> > 1-based (as opposed to the normal 0-based index). Unfortunately the[/color][/color]
author[color=blue][color=green]
> > of the ActiveX defines a 1-based array (to be passed to it) ByRef. So as[/color]
> far[color=green]
> > as I can tell I need to pass it a 1-based array. I'm new to .NET but[/color][/color]
I've[color=blue][color=green]
> > done some homework here and I know that the VB 6.0 "Option Base 1" and[/color]
> like[color=green]
> > alternatives are no longer supported. I have also gone back to the[/color]
> developer[color=green]
> > of the ActiveX object and asked them to write the #$%! object so I could
> > pass in a 0-based array, but that has gotten me nowhere.
> >
> > Any tips, hints, advice or solutions will be greatly appreciated. I've
> > attempted to add an extra row/column to the arrays and a properly[/color][/color]
bounded[color=blue][color=green]
> > 0-based array with no success. Here is some simplified sample code the
> > author provided so you have an idea what I'm trying to do.
> >
> >
> > Dim aryHdrParamList(1 To 4)
> > Dim aryLineParamMatrix(1 To 30, 1 To 5)
> >
> > aryHdrParamList(1) = "1"
> > aryHdrParamList(2) = "1"
> > aryHdrParamList(3) = "2GXCL0000"
> > aryHdrParamList(4) = "NONE"
> >
> > aryLineParamMatrix(1, 1) = "0532"
> > aryLineParamMatrix(1, 2) = Empty
> >
> > Set objMethod = CreateObject("Server.Service")
> > Call objMethod.GetInfo(aryHdrParamList, aryLineParamMatrix)
> >
> > MsgBox aryHdrParamList(1) & " " & aryHdrParamList(2) & " " &
> > aryHdrParamList(3)
> > MsgBox aryLineParamMatrix(1, 1) & aryLineParamMatrix(1, 4) & " " &
> > aryLineParamMatrix(1, 5)
> >
> >[/color]
>
>[/color]


Guest
 
Posts: n/a
#4: Nov 20 '05

re: 1-based index array issue


Oops. Had some issues with my newsgroup reader... the message above is from
me.

Thanks

"Ray Cassick (Home)" <rcassickNOSPAM@enterprocity.com> wrote in message
news:eLvfXI29DHA.2656@TK2MSFTNGP11.phx.gbl...[color=blue]
> I don't see why the indexing would matter between the two objects. If you
> create an array in VB.NET that is 0 bassed, say with elements starting at[/color]
0[color=blue]
> to 4 (5 elements) and then pass it to an object that takes the array, that
> object woul djust address them using 1 as the first element.
>
> "John Dolan" <john@coole.com> wrote in message
> news:O8luJKy9DHA.1636@TK2MSFTNGP12.phx.gbl...[color=green]
> > Hi all, I need some help here.
> >
> > I have an ActiveX object that requires me to pass in an array that is
> > 1-based (as opposed to the normal 0-based index). Unfortunately the[/color][/color]
author[color=blue][color=green]
> > of the ActiveX defines a 1-based array (to be passed to it) ByRef. So as[/color]
> far[color=green]
> > as I can tell I need to pass it a 1-based array. I'm new to .NET but[/color][/color]
I've[color=blue][color=green]
> > done some homework here and I know that the VB 6.0 "Option Base 1" and[/color]
> like[color=green]
> > alternatives are no longer supported. I have also gone back to the[/color]
> developer[color=green]
> > of the ActiveX object and asked them to write the #$%! object so I could
> > pass in a 0-based array, but that has gotten me nowhere.
> >
> > Any tips, hints, advice or solutions will be greatly appreciated. I've
> > attempted to add an extra row/column to the arrays and a properly[/color][/color]
bounded[color=blue][color=green]
> > 0-based array with no success. Here is some simplified sample code the
> > author provided so you have an idea what I'm trying to do.
> >
> >
> > Dim aryHdrParamList(1 To 4)
> > Dim aryLineParamMatrix(1 To 30, 1 To 5)
> >
> > aryHdrParamList(1) = "1"
> > aryHdrParamList(2) = "1"
> > aryHdrParamList(3) = "2GXCL0000"
> > aryHdrParamList(4) = "NONE"
> >
> > aryLineParamMatrix(1, 1) = "0532"
> > aryLineParamMatrix(1, 2) = Empty
> >
> > Set objMethod = CreateObject("Server.Service")
> > Call objMethod.GetInfo(aryHdrParamList, aryLineParamMatrix)
> >
> > MsgBox aryHdrParamList(1) & " " & aryHdrParamList(2) & " " &
> > aryHdrParamList(3)
> > MsgBox aryLineParamMatrix(1, 1) & aryLineParamMatrix(1, 4) & " " &
> > aryLineParamMatrix(1, 5)
> >
> >[/color]
>
>[/color]


Closed Thread


Similar Visual Basic .NET bytes