Text

Description

Obtains the text of an item in a ListBox control.

Applies to

ListBox, DropDownListBox, PictureListBox, and DropDownPictureListBox controls

Syntax

listboxname.Text ( index )

Argument

Description

listboxname

The name of the ListBox control in which you want the text of an item

index

The number of the item for which you want the text

Returns

String. Returns the text of the item in listboxname identified by index. If the index does not point to a valid item number, Text returns the empty string (“”). If any argument’s value is null, Text returns null.

Examples

Example 1

Assume the ListBox lb_Cities contains:

Example 2

Then these statements store the text of item 3, which is Chicago, in current_city:

string current_city

current_city = lb_Cities.Text(3)

See also