Results 1 to 5 of 5

Thread: How do I know if an array is empty or not?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    How do I know if an array is empty or not?

    Have you noticed that if you do the len() function on a filled array or if you do an ubound() function on an empty array you get errors?

    How do I work around this?

    thanks

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    I think isarray() will do it

  3. #3
    PowerPoster rjlohan's Avatar
    Join Date
    Sep 2001
    Location
    Sydney, Australia
    Posts
    3,205
    The reason is that you're not using those functions on an empty array - you're doing it on an array you've only declared, but never used, or given size or data to.
    -----------------------------------------
    -RJ
    [email protected]
    -----------------------------------------

  4. #4
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Try this

    VB Code:
    1. Dim MyArray(10) As String
    2. Dim Whole As String
    3. Whole = Join(MyArray)
    4. If Whole = Space(UBound(MyArray)) Then MsgBox "Array is Empty"
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216
    thanks for the input

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width