Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Loretta Carpenter   on Oct 31 In MS Office Category.

  
Question Answered By: Shannon Johnson   on Oct 31

Here is the code  for review:



Private Sub ListBox1_Click()

Dim i As Integer, iNumberSelected As Integer
'Create an array to hold the selected items.
ReDim sSelection(1 To ActiveDialog.Evaluate("ListBox1").ListCount) As
Single

With ActiveDialog.ListBoxes("ListBox1").List = Array("CSE", "LAW")
'Add item to sSelection if its item is True
For i = 1 To ActiveDialog.Evaluate("ListBox1").ListCount
If ActiveDialog.Evaluate("ListBox1").Selected(i) = True Then
'Add the item to sSelection.
sSelection(iNumberSelected) =
ActiveDialog.Evaluate("ListBox1").List(i)
End If
Next i

If iNumberSelected <> 0 Then
'Trim off elements not used.
ReDim Preserve sSelection(iNumberSelected)
'Return an array containing the selected item.
vSelection = sSelection
Else
'Return False if no items were selected.
vSelection = False
End If
End With

End Sub

Share: