Array count

sned

New member
Local time
Today, 00:38
Joined
Aug 14, 2001
Messages
8
How do I find how many items in an array?
 
Look up the UBound and LBound functions in VB help.
 
How do I find how many items in an array?

i stumbled on this 7yrs-and-counting post...
shacket is right to check the VB Help on UBound and LBound...
since i already checked the VB Help, oh well, will post the UBound here...

======================================================
UBound(arrayname[, dimension])
The UBound function syntax has these parts:

---------------
: arrayname :
---------------
Required. Name of the array variable; follows standard variable naming conventions.

---------------
: dimension :
---------------
Optional; Variant (Long). Whole number indicating which dimension's upper bound is returned.
Use 1 for the first dimension, 2 for the second, and so on. If dimension is omitted, 1 is assumed.
======================================================
 
ubound is a function, so you need to say, I think

itemsinarray = ubound(myarray)

bear in mind that the first item in an array is myarray(0),
so myarray(ubound(myarray)) will most likely produce a runtime error,

bear in mind also that this is not the same at all as saying, find the highest array index value that has been populated.
 

Users who are viewing this thread

Back
Top Bottom