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

Check to see if array has a value

Status
Not open for further replies.
Jul 14, 2003
116
CA
I am trying to figure out whether or not an array has a value. I thought I could do this buy taking using the ubound function but if the array has nothing in it I get an error with the ubound function. Then I thought I could use the isArray() function but since I declare my array as a dynamic array it returns true. Any ideas on how I can figure out whether or not the array has any values?
 
are you trying to check if there is anything in the array or just in a particular key
 
You can use the IsEmpty() function to test to see if your array is empty

-DNG
 
I was trying to check to see if there was anything in the array. I think I found a solution but let me know if you have something better. See below.

dim myArray()
dim myArray(-1)

if ubound(myArray) < 0 then
'There are no values in my array
end if
 
Whoops. The second dim should be reDim:

dim myArray()
reDim myArray(-1)

if ubound(myArray) < 0 then
'There are no values in my array
end if
 
or this should also work..

It would be Ubound(array_name) = -1 if its empty

-DNG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top