1-based index array issue

  • Thread starter Thread starter John Dolan
  • Start date Start date
J

John Dolan

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)
 
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.
 
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.
 
Back
Top