Length of an array in ASP by using UBound function
We can get the length or total number of element in the array by using UBound() function. Note that the index of the first element of the array is 0. So if there are five elements inside an array then the function UBound() will return 4. Here is the code to get the highest index of the array. Note that total element is 1 plus the highest index.
Dim myArray(3) 'Re-Declaring a dynamic array
myArray(0) = "UK"
Response.Write ("Total element of the array = " & UBound(myArray) )
for i=0 to uBound(myArray)
Response.Write "<br>" & myArray(i)
Here UBound is used to set the maximum looping length to display each element of the array.