Check if dynamic array dimensioned already

By | 2002-06-01

Tells if a dynamic array has been dimensioned or not.
Lu

Original Author: Newsgroup Posting

Code

Function Member(ary$(), text$)
  On Local Error GoTo MemberExit
  For i = 1 To UBound(ary$)
    If text$ = ary$(i) Then
      subscript = i
      Exit For
    End If
  Next
MemberExit:
  Member = subscript  
End Function
;========================================
another possibility;
Function ArrayElements(ary$())
  elements = 0    
  On Local Error GoTo MemberExit
  elements = UBound(ary$)
MemberExit:
  ArrayElements = elements
End Function

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.