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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to check array is empty or not

Status
Not open for further replies.

beeleegie

Programmer
May 15, 2002
42
HK
I have an object array, and I want to clear up the object in the array when the form unload. The I use a for loop to loop the object array. Unfortunately, the object array sometimes won't initialize (empty inside), then it will call error when calling lbound(Array). Do anyone know how to check the array contains something or not, or have a better method to clear the objects in the array. Thank you very much.
 
Dim intBound as Integer
On Error Resume next
intBound = Ubound(aryObj)
if Err.Number <> 0 then intBound = -1
On Error Goto 0
For I = 0 To intBound
.....
Next

But you could just
Erase aryObj ' assumming that it was defined
OR
Redim aryObj(0) ' no preserve
Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top