Split function

W

Wavequation

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

John Spencer

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

Douglas J. Steele

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
 
F

fredg

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top