SELECTIONINDEX

From Liberty BASIC Family
Jump to navigation Jump to search
Supported in Just BASIC Supported in Liberty BASIC Not supported in Liberty BASIC 5 Not supported in Run BASIC

Description

Returns the index number of the selected string in a Listbox or Combobox list.

Syntax

  1. print #handle.ext, "selectionindex? index"

Hints

Index Selection. The index numbers begin with "1" in a Listbox or Combobox control. Remember, index numbers might not match array numbers (an array can have an index "0" for instance), especially if array items have been deleted and the list has been reloaded.

Example

'Using SELECTIONINDEX? to obtain index number of selection
nomainwin
a$(1) = "apple"
a$(2) = "orange"
a$(3) = "banana"
a$(4) = "pear"

listbox #win.lst, a$(), [getIndex], 10, 10, 120, 200

    open "Select Index Demo" for window as #win
    #win "trapclose Quit"

    #win.lst "selectindex 1"
    wait

sub Quit handle$
    close #handle$
    end
    end sub

[getIndex]
    #win.lst "selectionindex? indexNum"
    notice "You chose Index number ";indexNum
    wait

Useful Procedures

' Place a useful function or sub using this keyword here