Split function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
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
 
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.
 
Back
Top