I’m working on a dialog with a listbox that has multi-select enabled. There is a confirm button on the dialog. How do I get all the selected items in the listbox when the user clicks the confirm button?
Your Confirm button can be attached to a macro. With the dialog as a global variable, the macro can access the list box and the items selected.
Sub getSelectedItems Rem get list box from dialog oListBox = myDlg.getControl("ListBox1") Rem get array of items oSelectedValues = oListBox.SelectedItems Rem check if anything selected If uBound(oSelectedValues) = -1 then MsgBox "Nothing Selected" Exit sub End if Rem loop through array for x = 0 to uBound(oSelectedValues) Print oSelectedValues(x) Next x End Sub