just do the same thing when you check for selections, but don't use the
for...next - loop :
Dim A As Integer
A = -1
Do
A = A + 1
If List1.Selected(A) Then
List2.AddItem List1.List(A)
List1.RemoveItem (A)
A = A - 1
End If
Loop Until A = List1.ListCount - 1
"Rob Tomson" wrote in message
news:FEDD39E5265E0516283F02BF7B4945D5@in.WebX.maYIadrTaRb...
> thanks, that works like a champ but now how do i remove the selected
items?
>
>
> "Veign" wrote in message
> news:A825845389D422F7EC8288E9B8630E81@in.WebX.maYIadrTaRb...
> > From the MSDN Library:
> >
> > MultiSelect Property Example
> > 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
> >
> > HTH
> >
> > --
> > Veign
> > Designing Solutions
> > www.veign.com
> > VB Code Samples & Projects
> > www.veign.com/information/info_main.html
> >
> >
> > "Rob Tomson" wrote in message
> > news:2F84D10178904090E0B54836376BDA78@in.WebX.maYIadrTaRb...
> > > i know how to do that but if i have more than one item selected then
> > > .listindex only returns the currently selected item. how do i remove
> (or
> > > add) them all?
> > >
> > > "Russell Cygan" wrote in message
> > > news:14DA20A663C69A9FAC2E00E71164F04C@in.WebX.maYIadrTaRb...
> > > > you can use the removeitem method. here's an example that you may be
> > able
> > > to
> > > > use in your code.
> > > >
> > > > lstExistBlks.RemoveItem (lstExistBlks.ListIndex)
> > > >
> > > >
> > > > "Rob Tomson" wrote in message
> > > > news:EFF239DEF7733338448E318E7BF69865@in.WebX.maYIadrTaRb...
> > > > > if i have a listbox with the multiselect property set to extended
> how
> > do
> > > i
> > > > > create a button to remove all the selected items or add them to
> > another
> > > > > listbox?
> > > > >
> > > > > thanks,
> > > > > Rob
> > > > >
> > > > > w2k, vb6, a2k2
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>