Use Ubound() to find the upper array boundary (zero based)
Dim t
Dim s
s = "The|Number|of|Elements|is|six"
t = Split(s, "|"
MsgBox "The number of elements in t is: " & UBound(t) + 1
Just a note. Do not be suprised to get a UBound of -1. It happens when the input string is zero length i.e. "". Be careful using the UBound of "t" to allocate other arrays.
Dim t() As String
Dim tLen() As Long
t = Split("", "|"
Redim tLen(Ubound(t)) ' SUBSCRIPT OUT OF RANGE
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.