Length of a variant string

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

I am getting an array (as a variant) from split function as below;

Dim arr
arr = Split(srcStr, ",")

How do I find the number of elements in the array?

Thanks

Regards
 
John said:
Hi

I am getting an array (as a variant) from split function as below;

Dim arr
arr = Split(srcStr, ",")

How do I find the number of elements in the array?

Thanks

Regards

Assuing you're using the default array base of 0, the number of elements
can be calculated as

UBound(arr) + 1

The lowest element subscript is LBound(arr) and the highest is
UBound(arr). Unless you've used the Option Base 1 statement,
LBound(arr) will be 0. If srcStr is a zero-length string, UBound(arr)
will be -1.
 

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

Back
Top