Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Remove Multiple Items From ListView


I've got a ListView control with the MultiSelect property set to True and would like to remove all of the selected items only. I've looked at some of the threads concerning this issue but am still having trouble. I can remove a single selected item but not all of the selected items. My code is as follows:


Code:
Private Sub cmdRemove_Click()

Dim I As Integer

For I = 1 To lstPlot.ListItems.Count
If lstPlot.ListItems(I).Selected = True Then
lstPlot.ListItems.Remove (I)
End If
Next I

End Sub


What am I missing?

Thanks for your help!




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Remove Multiple Items From A Listbox
How can I remove multiple items from a listbox?

I have tried this, but it won't work....


Code:
Dim i As Integer

For i = 0 To Me.lstFiles.ListCount - 1
If Me.lstFiles.Selected(i) = True Then
Me.lstFiles.RemoveItem Me.lstFiles.List(i)
End If
Next i

Remove Multiple Items From Listbox
Hi,

I have a listbox which is multiple selection enabled and I have a button which removes all selected items by looping through like so:


Code:
Do While PlayList.SelectedIndex <> -1
PlayList.Items.RemoveAt(PlayList.SelectedIndex)
Loop
This works, the problem is I have another piece of code which is triggered by the selected index being changed. It checks the count of the listbox and if empty does one thing and if not does another.

The problem is the selected index changes before the item is removed which means that even when the list is empty the count shows one and the program takes the wrong path.

Can anyone help?

Thanks
Stephen Reid

Listbox And Remove Multiple Items
i have this code for loading and removing items from a list box. i am generating an error with my remove item statment. i want to add the item at position i to the correct list box and also delete the item at postion i from both boxes. how i generate an invalid procedure call a the first removeitem command in either statement.

dim x as interger
x = 4

If card1Value > card2Value Then
MsgBox "card1 bigger " & card1 & " " & card2
For I = 0 To X
MsgBox I
lstDeck1.AddItem lstDeck1.List(I)
lstDeck1.RemoveItem lstDeck1.List(I)
lstDeck1.AddItem lstDeck2.List(I)
lstDeck2.RemoveItem lstDeck2.List(I)

Next
Else
MsgBox "card2 bigger" & card1 & " " & card2
For I = 0 To X
MsgBox I
lstDeck2.AddItem lstDeck1.List(I)
lstDeck1.RemoveItem lstDeck1.List(I)
lstDeck2.AddItem lstDeck2.List(I)
lstDeck2.RemoveItem lstDeck2.List(I)
Next I


any thoughts?

Remove Items From Listview?
Hi,

I have a listview which allows multiple selections. I want to place a button on the form which removes each selected item.

I'm having difficulty because VB renumbers each item index number as each item is removed. So item #2 which had an index of #2 now becomes #1. This would be no problem if the multiple selection was from item 1 to 5 where you could just loop through and remove index #1 5 times. But, what if the user selects items randomly?

Any help would be appreciated..

DAn

Remove Items From Listview In VB6
I have a listview1 control with 3 columns, CustId, CustName and CustContact. Each time I selected a row then clicked on the Command button to delete the selected row(s), it's not happening. Instead I got this error message "Element Not Found". I don't quite understand what it meant and how to get the deletion working. Could someone please point me to the right direction. Thanks.

Here is a my sample codes:
I am using Component Lib : MSCOMCTL.OCX (VB6)


Private Sub BtnSelectRemove_Click()

      'remove listitems from Attendance list
      Dim vclm As ColumnHeader
      Dim vitmx As ListItem
      Dim i As Integer
      
      With Me.ListAttendance
             For i = 1 To .ListItems.Count
                 If .ListItems(i).Selected = True Then
        .listitems.remove(.listitems(i))
                 End If
            Next
      End With

End Sub

Have a Good Day,

Thanks and Cheers,
Lennie

Edited by - Lennie on 2/9/2005 3:44:27 PM

Remove Selected Items In The Listview.
How I can remove the selected items in the listview?


Code:
For i = 1 To ListView1.ListItems.Count
If ListView1.ListItems.Item(i).selected Then

'what should I put here

End If
Next i

How To Remove Items From Listview Or Listbox ?
Hi all could any one show me i can delte item from both listview and listbox.Thanks

Remove Matching Items From Listview
I'm using a listview to load a list of email address's. What I'm trying to do is remove all address's from a selected domain using a GetExtension Sub to get the domain name. The problem is when I call the sub RemoveDomain() it removes the address I clicked on and all that come before it leaving those after it and not removing all from that domain. First I'm geting the domain extension in lblExt.Caption and that works fine. I'm trying to match that with the selected item in Listview and remove all those. I hope I've made this clear what I'm trying to do. Here's what I have so far.

Public Function GetExtension(ByVal p_strFileName As String) As String
If InStr(p_strFileName, "@") = 0 Then Exit Function

GetExtension = Mid(p_strFileName, InStrRev(p_strFileName, "@") + 1)
End Function

Private Sub RemoveDomain()
On Error Resume Next
Dim x As Long
x = 1
While x < ListView1.ListItems.Count + 1
Debug.Print x

If GetExtension(ListView1.SelectedItem) = lblExt.Caption Then
ListView1.ListItems.Remove x
Else
x = x + 1
End If
Wend

End Sub

Remove Multiple Listbox Items And Change Original
Ok, I have 2 list boxes in my form and by double clicking on one, it will add it to the other side, but what I want it to do is when it is double clicked, it will check if there is an item by the same name in the other, and if there is, not add a new item, but change the existing one by adding a number in front of it. Say I have a list box with the following items: Apple, Bannanna, Coke, Sprite, and Pepsi. When one of those is double clicked, it will check to see if there is already an item by that name in the second listbox, and if there is, change the first part or it to 2 Bannana or 3 Bannana if there is already 2. I have a feeling the way to go would be to use the mid function to check the beginning for the number and change that, but I dont know how to do that. I have found plenty of ways to check to see if there is an item by the same name, but I havnt found one that will change the original if there is. Any help would be appreciated.

Access 2002 - Remove Multiple Items In A List Box (Resolved)
In Access 2002, does anyone know the best method for removing selected items from a Multi-Select ListBox?

On my Form, I have one Multi-Select ListBox and one button that allows the user to delete the selected item(s) from
the ListBox. In my "btnRemoveTo_Click" event, I have tried the following 2 methods to remove the selected items from the list box. However, in my looping routine, when I issue the .RemoveItem command, all the items that were selected in the Multi-Select list box, become unselected, thereby leaving no items selected. For instance, if the user has 5 items selected, the first time the .RemoveItem code is issued the first item selected is Removed from the list box, but after that, all the items become deselected, leaving me with no items selected - therefore no other items are removed.

Code:Private Sub btnRemoveTo_Click()
Dim vItem As Variant, iRow As Integer
' Remove all the items selected from the list box.
With Me
    If .listSendTo.ItemsSelected.Count = 0 Then
        Exit Sub
    Else
        ' METHOD #1
        For iRow = .listSendTo.ListCount - 1 To 0 Step -1
            If .listSendTo.Selected(iRow) Then .listSendTo.RemoveItem iRow
        Next

        ' METHOD #2
        'For Each vItem In .listSendTo.ItemsSelected
        ' .listSendTo.RemoveItem vItem
        'Next
    End If
End With

End Sub


edit:: marked as resolved.



Edited by - Metallisoft on 5/19/2004 4:24:24 PM

Add Items To A Listview Multiple Columns
Hi... I have a listview with 3 columns... how can i add items to the second and the third column? i know it's a stupid question but i can't solve it


Thanks in advance

simons

Moving Multiple Listview Items Up Or Down At Once
Hi, does anybody know how to move multiple selected listview items up or down at once?

I found the subs below, but they only move one item up or down, even if I have selected multiple items.

Thanks.


vb Code:
Private Enum menmDirections    MoveUp = 1    MoveDown = 2End Enum Private Sub MoveItem(ByVal penmDirection As menmDirections)Dim lvwItem     As ListItemDim lvwNew      As ListItemDim lvwSubItem  As ListSubItemDim lngIndex    As Long    Set lvwItem = lstView.SelectedItem    If Not (lvwItem Is Nothing) Then        If penmDirection = MoveUp Then            lngIndex = lvwItem.Index + 2        ElseIf penmDirection = MoveDown Then            lngIndex = lvwItem.Index - 1        End If        If lngIndex > 0 And lngIndex <= lstView.ListItems.Count + 1 Then            Set lvwNew = lstView.ListItems.Add(lngIndex, , lvwItem.Text)            For Each lvwSubItem In lvwItem.ListSubItems                lvwNew.ListSubItems.Add , lvwSubItem.Key, lvwSubItem.Text, lvwSubItem.ReportIcon, lvwSubItem.ToolTipText            Next lvwSubItem            lvwNew.Selected = True            Set lvwNew = Nothing            lstView.ListItems.Remove lvwItem.Index        End If        Set lvwItem = Nothing    End IfEnd Sub



vb Code:
Private Sub MoveUp(lv As ListView)    Dim itm As ListItem, itmNew As ListItem, i As Long    If lv.SelectedItem.Index > 1 Then        Set itm = lv.SelectedItem        Set itmNew = lv.ListItems.Add(itm.Index - 1, , itm.Text, itm.Icon, itm.SmallIcon)        For i = 1 To itm.ListSubItems.Count            With itm.ListSubItems(i)                Call itmNew.ListSubItems.Add(, .Key, .Text, .ReportIcon, .ToolTipText)            End With        Next        lv.ListItems.Remove itm.Index        itmNew.Selected = True        lv.SetFocus    End IfEnd Sub Private Sub MoveDown(lv As ListView)    Dim itm As ListItem, itmNew As ListItem, i As Long    If lv.SelectedItem.Index < lv.ListItems.Count Then        Set itm = lv.SelectedItem        Set itmNew = lv.ListItems.Add(itm.Index + 2, , itm.Text, itm.Icon, itm.SmallIcon)        For i = 1 To itm.ListSubItems.Count            With itm.ListSubItems(i)                Call itmNew.ListSubItems.Add(, .Key, .Text, .ReportIcon, .ToolTipText)            End With        Next        lv.ListItems.Remove itm.Index        itmNew.Selected = True        lv.SetFocus    End IfEnd Sub

Listview - DragDrop Multiple Items
I have the following code that successfully will drag & drop one item at a time, but doesn't work all the time if multiple rows are selected?
When I start to drag, sometimes nothing happens.

Anybody point me in the right direction please?


Code:
Private Sub lvwSelected_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
On Error GoTo ErrTrap

Dim i As Long
Dim lvwItem As ListItem

For i = 1 To lvwSource.ListItems.Count
If lvwSource.ListItems(i).Selected = True Then
Set lvwItem = lvwSelected.ListItems.Add(, , lvwSource.ListItems(i).Text)
lvwItem.SubItems(1) = lvwSource.ListItems(i).SubItems(1)
lvwItem.SubItems(2) = lvwSource.ListItems(i).SubItems(2)
'remove original item
lvwSource.ListItems.Remove i
End If
Next

Also, when dragging multiple items across, and removing the original item, I now get an error because the ListItem.Count is now out of bounds.
How would I handle this?
Would I add 1 to the value of 'i' before the next loop?

Multiple Selected Items In A Listview
Hello, how can I find out how many selected items there are in a listview?

I'm showing a popup menu when the user right-clicks on an item, but I need to know if only 1 item is selected, so I can disable a menu option.

I've tried this, but it doesn't work.


VB Code:
If ListView.SelectedItem < 2 Then mnuCopyMultiple.Enabled = False

Dragging Multiple Items From A Listview
i have some code to let users drag an item from a listview onto a treeview node, which works fine, but now i want to let them drag multiple items.

the problem is that when then select a bunch of items, then drag them to the treeview, it leaves only the last item they clicked on selected (as if they selected them, then just left-clicked one of them). is there a way to keep them all selected?

also, just out of interest, is there a way to make the drag icon include some text from each selected listview item along with an icon (like when you drag multiple files in windows explorer)?

thanks for any help

Multiple Select Items In Listview
im having a problem in listview. ther ar 2 listviews for Excel and server. the user will select fields in th excel lisview he want to upload in server lisview. it upload a field if the user only select 1 field. but if it highlights many fields it only copy the lastselected fields the other fields highlighted dont work. heres my code:

j = LVExcel.ListItems.Count
 For i = j To 1 Step -1
  If LVExcel.ListItems(i).Selected = True And LVDatabase.ListItems(i).Selected = True Then
        Set rs1 = New ADODB.Recordset
        destinationtble = "select * from [user]"
        rs1.Open destinationtble, gcn, adOpenKeyset, adLockOptimistic
           Do While Not RS.EOF
              rs1.AddNew
              rs1.Fields(LVDatabase.SelectedItem.Text) = RS.Fields(LVExcel.SelectedItem.Text)
              rs1.Update
              RS.MoveNext
           Loop
          Set RS = Nothing
  End If
next i

Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!

I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!

Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.

To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!

Waiting for your valuable reply ...

Regards,

Ruturaj.

Drag Multiple Items From Listview To Treeview
Does anyone have some good sample code for how to
drag multiple listviewitems to an treeview?!

I cant figure it out...

Regards

Peter

Show Multiple Items In Listview Taken From Database
How would I show multiple items from an Access database in a listview?

Example: Let's say my database looks like this:

Sender Subject Date
me@isp.com Some Subject 1-13-00 7:59AM
you@otherisp.com Some other subject 7-30-01 8:00AM

I want to load both items into a listview. My current procedure only loads one item at a time. Here is the procedure:


Code:
Dim Recordset As ADODB.Recordset
Select Case Node.Text
Case "Trash"
If Recordset.EOF = True Then Exit Sub
lvwMail.ListItems.Clear
With lvwMail.ListItems.Add(, , Recordset!Sender)
.SubItems(1) = Recordset!Subject
.SubItems(2) = Recordset!Date
End With
End Select

How To Move Multiple Selected Items To New ListView
I have 2 ListView Controls. I need to move multiple selected items from ListView1 to ListView2.

How would I go about doing this?

Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!

I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!

Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.

To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!

Waiting for your valuable reply ...

Regards,

Ruturaj.

Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!

I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!

Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.

To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!

Waiting for your valuable reply ...

Regards,

Ruturaj.

Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!

I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!

Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.

To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!

Waiting for your valuable reply ...

Regards,

Ruturaj.

Remove Items In ListView With "zero" In First Column
How would I go about removing items in a listview that have a certain text typed in the first column (ListView1.ListItemm(i).ListSubItems(0).text)?

Remove Items
Is there a way that when I enter things into a ListBox and by mistake I enter one wrong can I remove it by typing in, in another TextBox the thing I just entered and hitting a CommandButton that will remove what was entered into the TextBox?

Or do you know of an easier way to remove an Item from a list of items in a ListBox?

Thanks

How To Remove Items From App Log File ?
Hello all,

I am using the App Loging feature to create a log file for logging events in my program. Everything is working fine except it's logging some additional stuff that I do not want nor have asked for;

Here's My Simple Code....
________________________________________________________________
Private Sub Form_Load()

Dim MyTime = Now()

' Sets App Event log path. Arg.2 forces logging to this path & File

App.StartLogging "E:Log.Txt", 2

'Log event writes MyTime & Message to E:Log.text. Required 2nd Arg. 4 specifies it's information

App.LogEvent MyTime & " Program Started", 4 '
'
End Sub
__________________________________________________________________


And Here's what the output looks like in my "Log.Txt" file.....

Information Application E:Log.Txt: Thread ID: 2100 ,Logged: 3/11/2005 6:01:44 PM Program Started


Here's What I want......

3/11/2005 6:01:44 PM Program Started


But I am willing to settle for this......

3/11/2005 6:01:44 PM Program Started :Information Application E:Log.Txt: Thread ID: 2100 ,Logged


Any Ideas or Suggestions?


Thanks.

Remove Listbox Items
Is it possible to remove items from listbox by giving item's name not it's index?
I mean if listbox has items Cat, Dog and Cow then what should I do if I want to remove item Dog, but not knowing what index it has?

List Box (Remove Items)
I have a listbox in which I load mp3's for an mp3 player, i also have a "Remove" button on my form, how would I remove JUST the selected song from the list, and not the entire list?? Thanks again!

How To Remove Items From A ComboBox?
Without knowing the number of items in it?

Thanks,

Guy.

Remove Combo Items
i need to remove items in a combo box that already exist in the list but im not sure how. i thought this code i wrote last night would work, but it doesnt, and i cant figure out why. any ideas?



Code:
For b = 1 To cboRecent.ListCount
'c is the array index
c = b - 1
'd is a value linked to c array index
d = cboRecent.List(c)
'nested for to find a match between d & the other items
For e = 1 To cboRecent.ListCount
f = e - 1
If cboRecent.List(f) <> d Then
'add item to list
cboRecent.AddItem (RECENTLIST)
End If
Next e
Next b

Remove Same Items From Two Listboxes!
i wanted to know an effective way to remove same items from two listboxes

for example in the same list box i have


1
2
4
5
6

and in the second
2
3
8
9
0
in this case i wanted 2 to be removed from one of the listbox!

please if u know anything help me!

Remove Items From 2 Lists
Hi, this forum has proved successful for me in the past so I thought Id give it a go.

I need help with code that will remove items from 2 lists.

For example when somebody clicks in the 1st item of List1 then clicks delete the 1st item in List1 and List2 will be deleted. If they click the 2nd item is List2 then click delete the 2nd item in List1 and List2 will be removed.

Please Help!

Remove Items From ListBox!
A VB6 project has 2 Forms named frm1 & frm2. Both the Forms have a ListBox named ListBox1 & ListBox2 respectively. Assume that the ListBox in frm1 is empty. When a CommandButton is clicked in frm1, frm2 loads.

The ListBox in frm2 lists country names from a text file. Users can select multiple items from ListBox2. After selecting items from ListBox2, when a OK CommandButton in frm2 is clicked, 3 things happen:

1. frm2 unloads & frm1 gets activated
2. the selected items in ListBox2 get deleted
3. those deleted items get added to ListBox1 in frm1

This is how I am doing it:
VB Code:
[u]code in [i]frm2[/i][/u]Private Sub cmdOK_Click()    Dim i As Integer     For i = ListBox2.ListCount - 1 To 0 Step (-1)        If (ListBox2.Selected(i) = True) Then            [b][color=red]frm1[/color][/b][color=red][/color].ListBox1.AddItem ListBox2.List(i)            'MsgBox ListBox2.List(i)            ListBox2.RemoveItem (i)        End If    Next i     'MsgBox frm1.ListBox1.ListCount    Unload MeEnd Sub
The problem I am facing is the selected items in ListBox2 get deleted & frm2 also unloads but the items deleted from ListBox2 don't get added to ListBox1 which exists in frm1.

I even debugged the code by stepping over each & every line; the code flow turned out to be exactly what I wanted but I don't understand why the deleted items from ListBox2 aren't getting added to ListBox1.

In order to further debug the code, I added the 2 MsgBox lines which are commented. Now if I select say India, Japan & China from ListBox2 & click the OK CommandButton in frm2, then the first MsgBox, as expected, shows India, Japan & China. The second MsgBox also correctly shows the ListCount of ListBox1 as 3!

What am I doing wrong here?

This is how I am invoking frm2 when a CommandButton is clicked in frm1:
VB Code:
[u]code in [i]frm1[/i][/u]Private Sub cmdAdd_Click()    Dim frm As frm2    Set frm = New frm2    Call frm.ShowMe(Me)End Sub [u]code in [i]frm2[/i][/u]Private frmOwner As FormPublic Sub ShowMe(OwnerForm As Form)    Set frmOwner = OwnerForm    Me.Show vbModeless, frmOwner    frmOwner.Enabled = FalseEnd Sub
I also added this small code snippet in frm1 to further debug the app:
VB Code:
Private Sub Form_Activate()    MsgBox ListBox1.ListCount    MsgBox Me.ListBox1.ListCount    MsgBox frm1.ListBox1.ListCountEnd Sub
Strangely after selecting 3 items from ListBox2, when frm1 gets activated, the first 2 MsgBox's wrongly show the ListCount of ListBox1 as 0 but the third MsgBox correctly shows the ListCount of ListBox1 as 3!

Why this eccentricity?

Remove All Items In Listbox.
How can I remove all items in a text box, i'm guessing its going to use a loop.

Clearing Add/Remove Items
I am trying to make my own setup1.exe

I've been modifying the original setup1.vbp.

Most of it works fine.

When i install the program and remove it , the item is still visible in the Add/Remove Programs section.

Everything is removed except it is still visible in this.

Can anyone tell me how I can make it so these items are removed also.

Advanced thanks

Remove Items From Listbox
I need to remove items from the listbox after they have been entered.
the list looks like this:

Book (30)
Orange (20)
Blanket (-10)
Apple (0)

Is there any way to remove the negative values and the zero values.
(I mean the whole line Blanket (-10) and they are not always the same) Sample code please.
Tia
Spiritwolf

Remove Items From Listbox
I'm loading junk files into a listbox where the user can place checks in the ones he wants to delete. It works fine but how do I remove the ones he deleted from the listbox? I can't get RemoveItem to work. Here's the code I'm using to delete the selected files.

Dim i
For i = 0 To lstFoundFiles.ListCount - 1
If lstFoundFiles.Selected(i) Then
Kill lstFoundFiles.List(i)
End If
Next i

Remove Items From A File
How would I remove a specific string of words from a text file, and then put them back, in a specific location in that same file?

***---Remove Listbox Items---***
if i have a number of items in a list box lets say a 100 and i want to remove 50 from the middle so 25 to 75. So how can i delete those items fromt he listbox. Al of this would be in a command button

Remove Array Items?
Hi again,

I've just made a string array by "split".

I just wonder if there is any ready method to remove an item so the array will be shrinked, or should I have to do it by myself?

Thanks!

List Box, Remove Items 1 By 1
I am using a progress bar with a list box. The plan was to have the progress bar move along as the items in the list box were deleted (the program has to go through other steps before removing an item, and this task can take a while to complete). Anyways, this is what I have to remove the items from my list box, however, it only seems to remove the even number items and leave other items in the list box:
Code:
For i = 0 To List1.ListCount - 1
    List1.RemoveItem i
Next i

Remove Items From List Box
why does when adding items to a list box all items are added according to index increment, but when items are removed only even items are removed????


thanks for your help

dave ...this is the code

Private Sub Command1_Click()
Dim Entry, i, Msg ' Declare variables.
Msg = "Choose OK to add 100 items to your list box."
MsgBox Msg ' Display message.
For i = 1 To 100 ' Count from 1 to 100.
Entry = "Entry " & i ' Create entry.
Debug.Print Entry & " "
List1.AddItem Entry ' Add the entry.

Next i
Msg = "Choose OK to remove every other entry."
MsgBox Msg ' Display message.
For i = 1 To List1.ListCount ' Determine how to


Debug.Print List1.ListIndex

Debug.Print List1.ListIndex
List1.RemoveItem (i)

Next i ' item.


Msg = "Choose OK to remove all items from the list box."
MsgBox Msg ' Display message.
List1.Clear ' Clear list box.

End Sub

Remove ListBox Items
Hi

Please tell me how to remove selected items from the listbox.

Wht i m using is here:

Dim i As Integer
i = 0
Dim Count As Integer
Count = lstAssignment.ListCount - 1
For i = 0 To lstAssignment.ListCount - 1
If lstAssignment.Selected(i) = True Then
lstAssignment.RemoveItem (i)
End If
Next i


it showing me an Invalid property array index

Please Help Me.

Thanx

Remove All Duplicated Items From A Listbox
i am filling a listbox with a lot of items then doing some stuff with that but then i want to delete all duplicated items. what is the best way because there will be a lot.

thanks

How Can I Remove Checked Items In A Listbox?
Hi,

I have a ListBox1 with a checkbox style and a cmdbutton.
How can i remove only the checked items in the listbox1?

Thanks,

Warad
yes i searched before i asked

Check Box To Remove Items From List?
I have made this progam that picks random things from two lists and displays them on a form. I was wondering if there is a way i can have it so when i check a check box labled one of the items in one of the lists will not show up anymore.

Remove Menu Items At Run Time
Hi, is it possible to remove items from menus added using the Menu Editor at run time?

Cheers

Remove Random Items From Listbox
Ok, I'm trying to remove 2 random items from a listbox at once. Then take the larger of the two randomly selected numbers and subtract the smaller from it. Then re-ad the ne number back into my listbox. This will repeat until only one number is left. Here's what i've got so far but I keep on getting error's.

Dim i As Integer
Dim Num As Integer
Dim Num1 As Integer
Dim j As Integer
Dim k As Integer
Dim f As Integer

Num = Round(Rnd * (List1.ListCount - 1), 0)
j = List1.List(Num)
Num1 = Round(Rnd * (List1.ListCount - 2), 0)
k = List1.List(Num1)

If j > k Then
f = j - k
ElseIf k > j Then
f = k - j
End If

For i = 1 To List1.ListCount
List1.RemoveItem (Num)
List1.RemoveItem (Num1)
List1.AddItem (f)
Next i


When I run this I get debug error 5 (Invaled procedure call or arguement) And it highlights "List1.RemoveItem (Num)" Any suggestions???

2 Listboxes-Remove Matching Items
VB Code:
'I searched and found this code that will copy all items from List1 to List2 if the'item isn't in List2.  What I'm trying to do is reverse it and Remove matching items'from List2 if they do exist in List1. 'Original Code  Dim i, j As Integer  Dim bMatch As Boolean  'this will take strings from list1 and add to list2  For i = 0 To List1.ListCount - 1    bMatch = False    For j = 0 To List2.ListCount - 1      If List1.List(i) = List2.List(j) Then        bMatch = True        Exit For      End If    Next j    'add list1 item to list2    If bMatch = False Then List2.AddItem List1.List(i)   Next i   'When I change it to remove the matching item it doesn't work   Dim i, j As Integer  Dim bMatch As Boolean  'this will take strings from list1 and add to list2  For i = 0 To List1.ListCount - 1    bMatch = False    For j = 0 To List2.ListCount - 1      If List1.List(i) = List2.List(j) Then        bMatch = True        Exit For      End If    Next j    'add list1 item to list2    If bMatch = True Then List2.RemoveItem List1.List(i)   Next i

Copyright © 2005-08 www.BigResource.com, All rights reserved