I am using the split function to load an array with substrings from a string.
The array does not have a declared dimension. Can I find out how many
substrings have been loaded?
John Spencer - 31 Oct 2007 19:45 GMT
Try the Lbound and Ubound functions.
UBound(SomeArray) will return the upper boundary of the array. LBound
returns the lower boundary of the array.
If you want to be absolutely sure of the number of elements, you can
subtract LBound From Ubound and add 1 to get the number of elements in the
array.
Normally Arrays are Zero-based, but they can be one-based.

Signature
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
.
>I am using the split function to load an array with substrings from a
>string.
> The array does not have a declared dimension. Can I find out how many
> substrings have been loaded?
Douglas J. Steele - 31 Oct 2007 19:47 GMT
The UBound function will give you the largest allowable value for the
dimension, while the LBound function will give you the lowest allowable
value. The number of elements in array MyArray would be UBound(MyArray) -
LBound(MyArray) + 1

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
>I am using the split function to load an array with substrings from a
>string.
> The array does not have a declared dimension. Can I find out how many
> substrings have been loaded?
fredg - 31 Oct 2007 19:49 GMT
> I am using the split function to load an array with substrings from a string.
> The array does not have a declared dimension. Can I find out how many
> substrings have been loaded?
Look up the UBound function in VBA help.
Arrays are 0 based so you would use
MsgBox UBound(ArrayName) + 1
A string like "Black,Red,Green,Blue"
using the comma as separator, will return an array value of 4.

Signature
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail