Item$ (function)

Syntax

Item$(text$,first,last [,delimiters$])

Description

Returns all the items between first and last within the specified formatted text list.

Comments

The Item$ function takes the following parameters:

 

Parameter

Description

 

text$

String containing the text from which a range of items is returned.

 

first

Integer containing the index of the first item to be returned. If first is greater than the number of items in text$, then a zero-length string is returned.

 

last

Integer containing the index of the last item to be returned. All of the items between first and last are returned. If last is greater than the number of items in text$, then all items from first to the end of text are returned.

 

delimiters$

String containing different item delimiters.

By default, items are separated by commas and end-of-lines. This can be changed by specifying different delimiters in the delimiters$ parameter.

Example

This example creates two delimited lists and extracts a range from each, then displays the result 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"
  list1$ = Item$(ilist$,5,12)
  list2$ = Item$(slist$,2,9,"/")
  MsgBox "The returned lists are: " & crlf & list1$ & crlf & list2$
End Sub

See Also

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

More information

I