This example fills a ListBox control with the names of your screen fonts and illustrates how the MultiSelect property affects the behavior of a ListBox. To try this example, create two ListBox controls and a CommandButton control on a form. In the first ListBox, set the MultiSelect property to 1 or 2. At run time, select several items in the first ListBox, and then click the CommandButton. All selected items are displayed in the second ListBox. Run the example several times with different settings of the MultiSelect property. Paste the code into the Declarations section, and then press F5 to run the program.
Private Sub Form_Load ()
Dim I ' Declare variable.
' Fill the list box with screen font names.
For I = 0 To Screen.FontCount - 1
List1.AddItem Screen.Fonts(I)
Next I
End Sub
Private Sub Command1_Click ()
Dim I ' Declare variable.
' Clear all items from the list.
List2.Clear
' If an item is selected, add it to List2.
For I = 0 To List1.ListCount - 1
If List1.Selected(I) Then
List2.AddItem List1.List(I)
End If
Next I
End Sub