Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

testing if an array is initialized 1

Status
Not open for further replies.

fenris

Programmer
May 20, 1999
824
CA
How would I test to see if an array is initialized?
Troy Williams B.Eng.
fenris@hotmail.com

 
Doh,
Thanks that is exactly what I was looking for!
Troy Williams B.Eng.
fenris@hotmail.com

 
It depends on how it is defined. You may have to use On error
Code:
    Dim v() As Integer
    Dim blnInit as boolean 
    If IsArray(v) Then
        blnInit = True
        On Error resume next        
            ' fails with subscript out of range
            Debug.Print UBound(v)
            if Err.Number <> 0 then blnInit = false
        On error goto 0 
    End If


    Dim v As Variant
    If IsArray(v) Then     ' Is not an array Ok.
        debug.Print UBound(v) 
    End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top