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

Checking number of items in an array 1

Status
Not open for further replies.

smgeorge99

Programmer
Jun 6, 2003
21
US
How do you check the number of items in an array? More specifically, how can you check to see if an array has nothing in it?

I have a function that returns an array of ID's for a particular table based on certain criteria. It is valid for no rows to be returned. If rows are returned, then I loop through the array and do some processing. If no rows are returned, I just want to move on without looping through the array.

I can't seem to get this to work properly. Any help is greatly appreciated.

 
Can you post the code you have now so that we can recommend additions?



"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
Check Help for the UBound and LBound functions.

I think you can use these to determine the size of the array and then take appropriate action.

HTH

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Dim i as integer
i = ubound(myarray)
If isnull(i)
Nothing there
Else
Has data
End If





 
If you have a function that returns the array of IDs, then you must be loading the array in that function. And I assume you're creating a recordset to accomplish that.

If that's the case, you can check the value of recordset.recordcount.

If recordset.recordcount = 0 then find a way to pass that value to the code that processes the array.

Possibly you can use the value of the function itself, unless of course you're passing the array itself out as the value from the function. In that case, maybe a module level or global variable will work.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top