Announcement

Collapse
No announcement yet.

length of array

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • length of array



    how do i find the length of an array, which has been declared as

    Code:
    Dim abcarray() As Variant

  • #2
    Re: length of array

    Hi Aadarsh,

    Try this:

    Ubound(array)


    HTH.

    Comment


    • #3
      Re: length of array

      Thanx

      Comment


      • #4


        Re: length of array

        The above solution doesn't work for zero-based arrays. Here's a complete example.

        Code:
        Option Base 0  'Un-comment for zero-based arrays
        'Option Base 1   'Un-comment for one-based arrays
        
        Sub ShowArrayLen()
            Dim abcarray() As Variant
        
            ReDim abcarray(3)   'i.e. some run-time array size value
        
            MsgBox "Range: " & LBound(abcarray) & " to " & UBound(abcarray)
            MsgBox "Length: " & UBound(abcarray) - LBound(abcarray) + 1
            MsgBox "Ubound: " & UBound(abcarray)    'does not = length for zero-based arrays!
        End Sub

        Comment

        Working...
        X