ItemCount (function)


ItemCount(text$ [,delimiters$])


Returns an Integer containing the number of items in the specified delimited text.


Items are substrings of a delimited text string. Items, by default, are separated by commas and/or end-of-lines. This can be changed by specifying different delimiters in the delimiters$ parameter. For example, to parse items using a backslash:

  n = ItemCount(text$,"\")


This example creates two delimited lists and then counts the number of items in each. The counts are displayed in a dialog box.

Const crlf = Chr$(13) + Chr$(10)

Sub Main()
  ilist$ = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15"
  slist$ ="1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19"

  l1% = ItemCount(ilist$)
  l2% = ItemCount(slist$,"/")
  msg1 = "The first lists contains: " & l1% & " items." & crlf
  msg1 = msg1 & "The second list contains: " & l2% & " items."
  MsgBox msg1
End Sub

See Also

Item$ (function); Line$ (function); LineCount (function); Word$ (function); WordCount (function).

More information