Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

split function question?

Status
Not open for further replies.

tommy19

Programmer
Aug 23, 2001
49
US
Hi all, silly question but I can't seem to find the answer, using:

t() = Split(string, "|")

How can I find the max items returned in t()?
 
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


Mark
 
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
Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top