Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Visual Basic (Microsoft) Versions 5/6 FAQ


Determine if a single dimensioned array is initialized by SBerthold
Posted: 20 Feb 09 (Edited 22 Feb 09)

This works for single dimensioned arrays.

The example is for a array of type STRING. For other types (Integer, Double, etc.) you need separate functions to pass those array types.


Public Function StrArrayIsDimensioned(MyArray() As String) As Boolean
    StrArrayIsDimensioned=((Not MyArray) <> -1)
End Function

You can test it using this:


Public Sub TestArray()
    Dim MyArray() As String

    If StrArrayIsDimensioned(MyArray) = False Then
        Debug.Print "Array is not yet dimensioned!"
    End If
    ReDim MyArray(10)
    If StrArrayIsDimensioned(MyArray) = True Then
        Debug.Print "Array is now dimensioned!"
    End If

End Sub

Of course you can check if the array is intialized without creating a separate function to do it:
If ((Not MyArray) <> -1) Then
    'Inspect the elements of the array
End If


Back to Visual Basic (Microsoft) Versions 5/6 FAQ Index
Back to Visual Basic (Microsoft) Versions 5/6 Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close