Determine if array contains no elements

J

Johan Verdouw

I am using Word 97 with Windows 98. On initializing a user form I want
to fill a listbox with values from an array. The array is filled in
another procedure. When the array contains no elements however, the
listbox should not be shown. Right now my code is like this:

Sub Initialize_Userform()

On Error Goto Err_Handler
(...)
lboListbox1.List = Array1
(...)
Err_Handler:
If Err.Number=380 then
'Code not to show listbox
End If

End Sub

Error 380 occurs when you try to populate a listbox with an empty
array. Is there another way to determine if an array contains no
elements? I know I can use UBound() and LBound() to determine upper
and lower boundary, but that function also generates an error if there
is no element in the array.

I have searched this newsgroup, but I could not find an answer to my
question. Hope somebody can help.

Regards,

Johan Verdouw
Trainer / Microsoft Office Specialist
 
K

Klaus Linke

Hi Johan,

Array1 is a variant? You could check out VarType(Array1).

Regards,
Klaus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top