Re: Setting based 1 Arrays



Michael C wrote:

Ok, let me see mike. I start a copy of vb6 and type in this code

Private Sub Form_Load()
Dim x(10)
x(0) = 5
End Sub

hmmmm, seems to me that that array is zero based. If the documentation says otherwise then it is wrong. Generally I don't have documentation from last century on my PC so no I have no read it. However, some other areas of vb6 are most definately 1 based. Which areas are 1 based and which are zero based appears to be random. You're not being very clear mike, perhaps you can cut and paste this mysterious piece of documentation you refer to. Does it say VB6 should be 1 based or zero based?

Michael, I can't confirm this under VB6 because my development machine desktop was corrupted early this year and I now notice I need to restore some lost VB6 dependencies. But in any case, I believe the issue is related to String Indexes more than arrays.

For example:

dim x as string
x = "123456789"
dim i as integer
for i = 0 to Len(x)
print " x(";i;") = "; x(i)
next i

Expected result:

x(0) = 1
x(1) = 1
x(2) = 2
x(3) = 3
x(4) = 4
x(5) = 5
x(6) = 6
x(7) = 7
x(8) = 8
x(9) = 9

As a side note, I was never aware of Tom's input with

OPTION BASE 1

I probably would not have used it in our WCVB.BAS header interface file because it has the explicit lower and upper range defined for the arrays field we have.

Type Tuser
...
security(1...NUM_USER_SECURITY) * String * SIZE_SECURITY
...
End Type

But overall your point is proven - VB.NET is not VB6. The old rules do no apply anymore. :-)

--
.



Relevant Pages

  • Re: Setting based 1 Arrays
    ... Option Base statement, or to the default setting of zero if you have not ... It's all clearly described in the documentation. ... Arrays: If the lower bound is not explicitly delcared, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Conversion Problem
    ... My overall intent is to convert an existing VB6 application into vb.net so I can still use multiple records I created in the new application. ... vb8 does not support arrays declared like arr1because when you try to do the Fileput it just gives an error saying only 2 dimentional arrays are supported - what a load of tat!!! ... dim arr1 ...
    (microsoft.public.dotnet.languages.vb)
  • Re: sharing a collection between vbsript and vb6
    ... > call it from VB6? ... VBS is limited to variant data types. ... subtype. ... are differently structured than are collections, and even VBS's arrays are ...
    (microsoft.public.scripting.vbscript)
  • Re: Unpack When? Part II
    ... the server date only. ... sparse arrays which allows cross-referencing ... Null and zero are almost always the same so don't ... get the .thisiscool property value by ...
    (comp.databases.pick)
  • Re: Array puzzle
    ... Further reading discourages using assumed size arrays. ... could you please point to that particular piece of documentation? ... > SUBROUTINE P2 ... but I can't find any similar thing I can do in P2's INTERFACE block. ...
    (comp.lang.fortran)