ex.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
ListIndex Property Example
                        Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
' This example displays the names of three players in a combo box and the
' corresponding salary of the selected player in a label.
 
' To try this example:
' 1. Choose New Project from the File menu
' 2. Choose New Form from the File menu to create a form with:
'    • Combo box
'    • Label
' 3. Set properties:
'    • For combo box, Style = 2 (Simple Combo)
'    • For label, AutoSize = True
' 4. Press Alt+F4 to return to the programming environment
' 5. Copy the code example below to the form module
' 6. Press F5 to run the example
 
 DIM SHARED Player$(0 TO 2)          ' General declarations
 DIM SHARED Salary$(0 TO 2)          ' Dimension two arrays
 
 SUB Combo1_Click ()                 ' Display corresponding salary for name
     Label1.Caption = Salary$(Combo1.ListIndex)
 END SUB
 
 SUB Form_Load ()
     Player$(0) = "Murphy McPhoo"    ' Enter data into arrays
     Player$(1) = "Alf Hinshaw"
     Player$(2) = "Woofer Dean"
     Salary$(0) = "$234,500"
     Salary$(1) = "$158,900"
     Salary$(2) = "$1,030,500"
     FOR I% = 0 TO 2                 ' Add names to list
         Combo1.ADDITEM Player$(I%)
     NEXT I%
     Combo1.ListIndex = 0            ' Display first item in list
 END SUB