[Gambas-user] ubound lbound

ron ronstk at ...239...
Tue Apr 6 07:33:26 CEST 2004


On Tuesday 06 April 2004 06:36, Frank Berg wrote:
> hi,
>
> how can i ask ubound and lbound values in an array
>
> snip ---------------------
>
>     dim s as string[]
>
>     s=split("1 2 3 4"," ")
>
>     print lbound(s)
>     print ubound(s)
>
> output ------------------------
>
>     lbound=0
>     ubound=3
>
> snap -------------------------
>
>
> frank

Good question

For gambas the arrays start always at 0 that is easy,
the ubound is simple the same as s.Count-1

What you had in VB are symbolic index numbers, just as indexes with words
You could delete/remove the first element and the index of the 
remaining stay the same, but are not true in numerical sequence.

The closed to this VB model is using a collection. 
Here the index can be a name or number (as string).

Removing a entry in the collection does not change the index name 
and are called as Key in gambas.

However lbound and ubound are still the same as for normal 
arrays, lboud=0 ubound=collection.count-1







More information about the User mailing list