Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why one over another: UBound or Length

Tags:

vb.net

Could there be any specific reason why one can choose UBound over Length?

Here is the code and 1-dimension is passed as second parameter.

    For iIndex = 0 To UBound(myList)
        If Left(Request.ServerVariables("REMOTE_ADDR"), Len(myList(iIndex))) = saIPList(iIndex) Then
            bAuth = True
            Exit For
        End If
    Next

Any performance gain against Length

like image 320
Tarik Avatar asked Sep 01 '11 20:09

Tarik


People also ask

What is UBound function?

The UBound function is used with the LBound function to determine the size of an array. Use the LBound function to find the lower limit of an array dimension. UBound returns the following values for an array with these dimensions: Statement. Return Value.

What is UBound and LBound in VBA?

The LBound function is used with the UBound function to determine the size of an array. Use the UBound function to find the upper limit of an array dimension.

How does UBound work VBA?

UBOUND, also known as Upper Bound, is a function in VBA with its opposite function, LBOUND or Lower Bound function. This function defines the length of an array in a code. As the name suggests, UBOUND is used to define the upper limit of the array.

What is UBound in vbscript?

The UBound function returns the largest subscript for the indicated dimension of an array. Tip: Use the UBound function with the LBound function to determine the size of an array.


1 Answers

They do different things! UBound gives you the last index in the array, while Length gives you the length. Those are not the same, because usually UBound will be Length - 1.

like image 190
R. Martinho Fernandes Avatar answered Nov 16 '22 02:11

R. Martinho Fernandes