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
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.
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.
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.
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With