Getting the upper bound index of an integer array

  • Thread starter Thread starter Jerry West
  • Start date Start date
J

Jerry West

I'd like to get the upper bound index of an integer array. I've tried the
following:

Dim i as Integer
Dim arrayIng() as Integer

i = arrayIng.GetUpperBound

This doesn't work. It seems GetUpperBound behaves more like a function in
that it wants a passed parameter. Is there not a property similar to VB6
like: i = UBound(arrayIng)

I realize that's still possible in VB .NET but isn't there a newer way of
doing it in VB .NET?

JW
 
Jerry West said:
I'd like to get the upper bound index of an integer array. I've tried the
following:

Dim i as Integer
Dim arrayIng() as Integer

i = arrayIng.GetUpperBound

This doesn't work. It seems GetUpperBound behaves more like a function in
that it wants a passed parameter. Is there not a property similar to VB6
like: i = UBound(arrayIng)

I realize that's still possible in VB .NET but isn't there a newer way of
doing it in VB .NET?

JW

It wants to know which part of an array you want the upper bound. Gets the
upper bound of the specified dimension in the System.Array. In your case
pass 0.

Hope this helps
Lloyd Sheen
 
Jerry,

I never use the upper bound or whatever.

Array.length - 1 = the latest, Array(0) is the first.

It is a pitty that in the first VB.Net beta time there is decided to keep
for real arrays a kind of compatibility with VB6 with the result now that it
keeps real arrays in VB.Net a troublefull situation.

An array in VB.Net is created with one extra in a way that you can use the
length and the count, however as well the bounds. To keep projects with
interchangeble languages, I will always avoid in this the starting index 1.
Be aware that this 1 extra is only for true arrays and the old not
Icollection implementing VB.Net collection. For the rest all lists and
collections and the generic versions of that behave as in all languages in
dotNet from zero to the length of the array.

Cor
 
Back
Top