By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,617 Members | 1,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,617 IT Pros & Developers. It's quick & easy.

1-based index array issue

P: n/a
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)
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <jo**@coole.com> wrote in message
news:O8**************@TK2MSFTNGP12.phx.gbl...
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)

Nov 20 '05 #2

P: n/a
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)" <rc************@enterprocity.com> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
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" <jo**@coole.com> wrote in message
news:O8**************@TK2MSFTNGP12.phx.gbl...
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)


Nov 20 '05 #3

P: n/a
Oops. Had some issues with my newsgroup reader... the message above is from
me.

Thanks

"Ray Cassick (Home)" <rc************@enterprocity.com> wrote in message
news:eL**************@TK2MSFTNGP11.phx.gbl...
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" <jo**@coole.com> wrote in message
news:O8**************@TK2MSFTNGP12.phx.gbl...
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)


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.