Home > Language Reference > Windows Management Functions > SelectedItem$

SelectedItem$

The SelectedItem$ function returns the currently selected item of a listbox or combobox.

Usage

Used to retrieve the text of an item in a list. Only standard Windows list/combo work with SelectedItem$. With a non-standard list/combo, you can use Clipboard :
SendKeys("<Ctrl c">)
to copy the text to Clipboard, and GetClipboard$ function to retrieve the content of Clipboard.  

Syntax

var$=Selectedtem$(<window_name>)

Parameters

<window_name>, string, window name of the listbox/combobox.

Return value

var$, string, text of the selected item. If the item does not exist, no error is reported and the return value is empty (an empty string is "").

See also

ListItem$

Example

'launch notepad
Shell("notepad",1)
'Select Edit/Font menu
UseWindow("NOTEPAD.EXE|Notepad|Untitled - Notepad",1)
ChooseMenu(Normal,"F&ormat|&Font...")
a$=SelectedItem$("NOTEPAD.EXE|ComboLBox|Font|2")
msgbox(a$)   'a$ returns the selected Font Style