Subject: How do I test for an empty array element
Posted By: kmoran Post Date: 10/7/2004 5:05:21 PM
Hi!

How do I test for an empty array element?
I want to loop through an array while the array element is not empty.

Say I have an array of 3 elements:

a(1) = 1
a(2) = 2
a(3) = is empty

How can I test for a(3) being empty?

Thanks!

K Moran
Reply By: gcianfanelli Reply Date: 10/8/2004 3:34:18 AM
Use the IsEmpty function, if your array contains items of a Variant type, eg.


Public Sub testForEmpty()
  Dim myArray(3)
  Dim item
  Dim counter As Long
  
  myArray(0) = "string value"
  myArray(1) = 1.5
  myArray(3) = False
  
  For Each item In myArray
    If IsEmpty(item) Then
      Debug.Print "Item " & counter & " in the array is empty"
    End If
    counter = counter + 1
  Next
End Sub


In the above example, myArray(2) is returned as empty

Go to topic 20051

Return to index page 750
Return to index page 749
Return to index page 748
Return to index page 747
Return to index page 746
Return to index page 745
Return to index page 744
Return to index page 743
Return to index page 742
Return to index page 741