UBound function Returns the highest available subscript for the indicated dimension of an array.

Parameters:

Array

Required. Array of any data type. The array in which you want to find the highest possible subscript of a dimension.

Rank

Optional. Integer. The dimension for which the highest possible subscript is to be returned. Use 1 for the first dimension, 2 for the second, and so on. If Rank is omitted, 1 is
assumed.

Return Value:

Integer. The highest value the subscript for the specified dimension can contain. If Array has only one element, UBound returns
0. If Array has no elements, for example if it is a zero-length string, UBound returns -1.

As others mentioned, The function UBound returns the highest available subscript for the indicated dimension of an array.

If arrays like below.

Dim arrayTest1 As String() = New String() {"a", "b", "c"}
Dim arrayTest2 As String() = New String() {"1", "2", "3", "4"}

Then UBound(arrayTest1) is 2, UBound(arrayTest1) is 3. If we get value by the subscript. arrayTest1(UBound(arrayTest1)) is "c" and arrayTest2(UBound(arrayTest2)) is "4".

Hope this helps. Thanks.

Best Regards!

We are trying to better understand customer views on social support experience. Click HERE to participate the survey. Thanks!

Member

54 Points

1286 Posts

## vb problem

Oct 16, 2013 11:09 PM|-_-|LINK

i don't know the following code, anyone help!~ (vb)

uBound?

All-Star

50841 Points

9895 Posts

## Re: vb problem

Oct 16, 2013 11:11 PM|A2H|LINK

Hi,

UBound function Returns the highest available subscript for the indicated dimension of an array.

Parameters:Array

Required. Array of any data type. The array in which you want to find the highest possible subscript of a dimension.

Rank

Optional. Integer. The dimension for which the highest possible subscript is to be returned. Use 1 for the first dimension, 2 for the second, and so on. If Rank is omitted, 1 is assumed.

Return Value:Integer. The highest value the subscript for the specified dimension can contain. If Array has only one element, UBound returns 0. If Array has no elements, for example if it is a zero-length string, UBound returns -1.

Refer the below link

UBound FunctionAje

My Blog | Dotnet Funda

Member

54 Points

1286 Posts

## Re: vb problem

Oct 17, 2013 11:20 AM|-_-|LINK

for my coding provided on the first post.

here is different cases, what is the result of Session("ID")??

case 1:

if i set ID="aaaa\bbb";

what is the result of Session("ID")?

is Session("ID")="bbb"?

case 2:

if i set ID="aaaa\bbb\ccc";

what is the result of Session("ID")?

is Session("ID")="ccc"?

ubound to return the highest subscript that means the highest index of array it returns????

Member

54 Points

1286 Posts

## Re: vb problem

Oct 18, 2013 02:30 AM|-_-|LINK

anyone answer me?

All-Star

30411 Points

3628 Posts

## Re: vb problem

Oct 21, 2013 05:50 AM|Fuxiang Zhang - MSFT|LINK

Hi,

As others mentioned, The function

UBoundreturns the highest available subscript for the indicated dimension of an array.If arrays like below.

Then UBound(arrayTest1) is 2, UBound(arrayTest1) is 3. If we get value by the subscript. arrayTest1(UBound(arrayTest1)) is "c" and arrayTest2(UBound(arrayTest2)) is "4".

Hope this helps. Thanks.

Best Regards!