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




Remove Item From 2 List Boxes


Hi!

I have 2 list box controls with same values - the first list is sorted and the other one is not. I hide/show approprate lists if user wants sorted/unsorted items.

Now I would also like to let the user to delete items from the list - deleting from one list is simple, but how can I delete the same entry in another one (as the list index is not the same)?

I guess it could work by looping thorugh the list and deleting the list entry that has the same text, but is there and easier way?

Bostjan




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
List Boxes Remove Item
how would you remove an item from a list box?

LIST BOX HELL. Please Save, Remove Items, Many List Boxes...one Last Name
ok, so the code so far, or as much as you need to see, is
****************************
***************************
***************************
***************************
***************************

Sub LoadCal()
Dim gdtDate As Date
Dim i As Integer
Dim x As Integer
Dim startDay As Integer
Dim giMaxDays As Integer

' clear list boxes before filling again
For i = 0 To 41
List1(i).Clear
Next

' * * * * * * * * * * * * * * * * * * * * * *
' * * * * * ADD DAY NUMBERS * * * * *
'label at top of form
Label1.Caption = MonthName(giMonth) & " " & giYear

'this is the current date
gdtDate = CDate(giMonth & "/01/" & giYear)

'minus one so the first line is never completely empty
startDay = Weekday(gdtDate) - 1

'the number of days in this month
giMaxDays = Day(DateAdd("m", 1, gdtDate) - 1)

'populates list boxes with days
x = 1
i = startDay
While i < (giMaxDays + startDay)
List1(i).AddItem (x)
x = x + 1
i = i + 1
Wend

' * * * * * * * * * * * * * * * * * * * * * *
' * * * * * ADD NAMES TO DAYS * * * * *

' !!!!!!!!!!!!!!!!!check to see that list is not empty !!!!!!!!!!!
If lstAgentList.ListCount = 0 Then GoTo done
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

'agent list counter, "at which item" index
x = -1
'populate list boxes from the first day of the month with numbers
i = startDay
'counter for number of days until sunday
a = startDay - 1

'from the first day to the last day
While i < (giMaxDays + startDay)
If a < 6 Then
'a maximum of 3 names per day
While (List1(i).ListCount) < 4
' if there are no more items in the items list ('x' is greater than counter)
If x < (lstAgentList.ListCount - 1) Then
x = x + 1
' otherwise set it back to 0 (zero)
Else
x = 0
End If
'add the next name from the established agent list
List1(i).AddItem (lstAgentList.List(x))
Wend
a = a + 1
Else
'a maximum of 3 names per day
While (List1(i).ListCount) < 4
'add the next name from the established agent list
List1(i).AddItem (lstAgentList.List(x))
'here we do not increment name for it is a sunday
Wend
'reset 7 days until sunday counter
a = 0
End If
'increment day count
i = i + 1
Wend

done:
' end
End Sub



***************************
***************************
***************************
***************************
now see the shaddy thing with this is...well, it's a calendar month see, and every day is a list box....first item, the date, 1st, 2nd, 3rd, 4th, and so on...each list box can hold that first item, the date, plus 3 names.

if someone double clicks on one of those names (which are populated through other methods...not important) i want that name to be deleted...now where i am out of ideas is: how do i delete one item from one list when my list (List1) is an array of about 41 list boxes all named List1 (x) see....

also if I wanted that name which was double click to delete itself through the entire month, then ....well...the rest is my own trouble...but so far i can't seem to be able to delete.

grrr.
...

thanks in advance,
-munchkin

List Box Remove Item
Ok i need to remove a list box line when it is selected and then when i hit a command button it removes it as well as the same line in the other list boxes. The list boxes are in an array.

Remove Item From List???
I have a really simple problem, well for you guys anyway. For some reason it won't let me delete an item from the list once I have clicked on it. I get a 'type mismatch' error.


Code:
FuelDelete = lstFuel.Text
lstFuel.RemoveItem FuelDelete

Any ideas why this is happening?
Thanks to whoever can help me

Remove End Of Item In List
I need to search a listbox and if it has a item with :: in it i need it to remove the :: from the item. The :: is always at the end of the item if that makes a difference.

List - Remove Item
I have a list where the user is able to add data to, but I want them to be able to remove items also. I have a remove buttom where once clicked I have some code, but I don't know how to specify which one to be removed. I obviously want the item selected in the list ot be removed, but I don't know how... Here's what I have now


VB Code:
Private Sub cmdRemoveBuddy_Click()    lstBuddies.RemoveItem    ' RemoveItem requires an integer, I'm guessing the index number of the list item..End Sub


Help? Thanks!

Remove An Item From A List Box
I am using the following code to remove an item from a lisbox.

Private Sub cmdRemove_Click()
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) Then
List1.RemoveItem i
End If
Next
End Sub

However when there is only 1 item in the list box, it is not deleted, and i want it to become deleted. Please help!!!

Remove Item From List-Box
How do I remove a secected Item from a List-Box?
I only know this method:

LIST1.REMOVEITEM # '# = Number of Item.

This method is ver uncomfortable, because I have to
enter the number of the Item I want to remove and
if I want to remove 2,3,4,.... Items it's very hard,
too.

Thanks for some advice, Matt

List Box Remove Item
Hi,
After my list box item has been processed, I need to delete the item.
I used the blow code:

Dim y As Integer
y = lstPracticeList.ListCount
For i = 1 To y
Update_Practice_Table (lstPracticeList.List(i - 1))
lstPracticeList.RemoveItem (i - 1)
Next



My problem is if I deleted one item the list box's list(i-1) will not
point to the next item on the list any more.

I can create two loops: 1. to read the list. 2. to delete after all the
reading.

Is there any way to read one list and delete one within one loop?

Your help is appreciated.

Remove An Item From A List Box
I have a list box named lstDraftPool that displays the contents of 3 seperate columns in a database for many individuals.
On the click event handler for the list box, the individual and their info is displayed in a 2nd list box named lstTeam1.

I used this code to do this.......

Code:lstTeam1.AddItem lstDraftPool.Text

Now, the text that I just displayed into the 2nd list box needs to dissappear and not be visible from the original list box.
I tried.........

Code:lstDraftPool.RemoveItem lstDraftPool.Text

but I keep getting Runtime Error :'13' type mismatch. Any suggestions ??? Thanks in advance !

Remove Last List Item
Can someone please tell me how to remove the last item in a listbox.

Remove Item From Drop Down List
On my site I have a drop down list (set to multiselect) which lists all of my users and I want to be able to select as many users as I want in the drop down list then click a button to remove them.

Can anyone help me out?

Thanks.

Please Help: Can't Remove Item From List (collection)
Explanation:
When the case form loads, the ucboProbationOfficer displays all officers from a sproc that brings all officers, regardless of inactive or active for historical data. When you select cmdNew on this form, we want the users to see only the active officers, so now I want to check if each officer in user combo box (ucboProbationOfficer) is active. If it's not active, remove it from the combobox which is derived from Collection colOfficers and Class clsOfficers

Note:
First try, I did have the following, but when it got to record 25 out of 30, it kept going to Terminate class and got subscript out of range error (5 records of 30 are inactive). So hardcoded it to 25 for now.

1st time tried: For p_lngItem2 = 1 To p_counterholder

------------------------------------------------------------------
Private Sub AssignEdit2()

Dim p_colOfficer As COLOfficers
Dim p_lngItem2 As Long
Dim p_lngRecord2 As Long
Dim p_vntItem2 As Variant
Dim p_counterholder As Variant

Set p_colOfficer = New COLOfficers
p_colOfficer.Load

p_lngRecord2 = 0
'p_counterholder = p_colOfficer.Count
For p_lngItem2 = 1 To 25 'p_counterholder

If p_colOfficer.Item(p_lngItem2).IsActive = False Then
p_colOfficer.Remove (p_lngItem2)
End If

Next p_lngItem2

--------------------------------------------

Results: Get same data, all officers so did not remove officers. Is this correct sytax?

List Remove Item Button
i currently have one list box and a remove button. i want it so that when i click on the button it will remove the selected text in the list box, i have tried a few thing but none work.

thanks
lee

Remove Item From Window List
Hello Guys. Prob not possible... but is there any way not through the API to remove a form from the File Menu Windowed List... I have some toolbars that are going to stay up there the whole time anyways, so having them just out of the window list makes perfect sense.

If it can't be done w/o api, what is the code.

Remove Item From Drop Down List
On my site I have a drop down list (set to multiselect) which lists all of my users and I want to be able to select as many users as I want in the drop down list then click a button to remove them.

Can anyone help me out?

Thanks.

Remove Item From List Box + Reverse Cost
When i click a product, click cmd add, its properties are displayed on the listbox. The products have cost which are displayed on lbltotalcost and adds up.

Now when I lick cmdRemove, I remove an item from the listbox but how do I make it so that lbltotalcost also removes the cost of that product so it kinda totalcost-productcost

ListView - Remove The Selected Item In The List
as per the heading how on earth do i remove the selected item in a listview. I did it like the below in a listbox but cant find any reference to a listindex in the list view. PLease help me I am going slowly insane over this little problem.



VB Code:
lstMovedFiles.RemoveItem (lstMovedFiles.ListIndex)

List Box Q, Remove An Item, By Value Not Index? *solved*
Is there an easy method to remove an item from a list box, if there is more then say, one item in the list for a particular Value etc?

Say i have a list:

Wayne
Joe
Fred
Bob
Fred


And my server sends the message to the client "Remove Fred", (I have this bit working ),
How can i remove both "Fred"'s without knowing their ListIndex's?

Tnx

Remove Item Form List And File...
hi there,

i can remove an item from a listbox with this code:


PHP Code:




Dim x As Integer

List1.RemoveItem (List1.ListIndex)
List1.Refresh
MsgBox (List1.Text)
Open "\ocp0nt1softmet$ estapplog.txt" For Output As #1
For x = 0 To List1.ListCount - 1
    Print #1, List1.List(x)
Next x
Close #1







But i can't get the selected item into a string. I want this cause i have to rewrite this string and put it back, like an correction...

plz help

Remove Empty List Item After Labeledit
I have a button that inserts a new item in a listview, then starts labeledit. The problem is that I want it to remove the list item if the list item text = "". I looked at code to do this for a treeview but it wouldn't work for the listview.

Here's the treeview code if it helps:

Code:

Option Explicit

Private Sub Form_Load()
With TreeView1

.Nodes.Add , , "MyNode01", "Enter a description here"

.Nodes("MyNode01").EnsureVisible
.Nodes("MyNode01").Selected = True
.LabelEdit = tvwManual
.StartLabelEdit
End With
End Sub

Private Sub TreeView1_AfterLabelEdit(Cancel As Integer, NewString As String)
'if edited - changed, thgis should trick
If NewString = "Enter a description here" Then

End If
End Sub
Private Sub TreeView1_GotFocus()
'if not edited, this will trig
With TreeView1
If .Nodes.Count > 0 Then
If .Nodes("MyNode01").Text = "Enter a description here" Then
.Nodes.Remove "MyNode01"
End If
End If
End With
End Sub

Selecting The Nth Item In Several List Boxes
Hi

I was wondering is it possible to select say the fourth item in several list boxes so they are all highlighted in the same place. The coding would be greatly appreciated!

Parsing Item Between List Boxes
Code:
For n = 0 To List1(0).ListCount - 1
report.List1(0).List(n) = List1(0).List(n)
report.List1(1).List(n) = List1(1).List(n)
report.List1(2).List(n) = List1(2).List(n)
report.List1(3).List(n) = List1(3).List(n)
report.List1(4).List(n) = List1(4).List(n)
report.List1(5).List(n) = List1(5).List(n)
report.List1(6).List(n) = List1(6).List(n)
report.List1(7).List(n) = List1(7).List(n)
Next


what I'm doing in the code is to parse the item in list1 to report.list1
but when the list is having a large number of data/items, the parsing will become slower.
is there any way can cover it?

Moving Item Between List Boxes
I have a command button with the Caption ">". When clicked I want the selection the user has made in ListBox1 to be moved to ListBox2.

Anyone ever do something like this before?

thx..

ComboBox List/add Item, If Item Exists, Dont Add It Again!
Dudes and Dudeesses I need help!

I have a problem with a combobox within a form. I'm scanning down the spreadsheet for values and asking a combobox to .additem, however, the same value may appear twice whilst scanning down. Is there an if statement that will look and check the combobox to see if it is already added, if so dont add it again, if not, add it?

as below,

Code:
combobox.AddItem "Hotmail"
combobox.AddItem "Yahoo"
combobox.AddItem "Hotmail"
Hotmail will be added twice, how can I stop that?

If worst comes to the worst, I can sort it out with a long winded method, but I'm hoping theres a quicker way.

Thanks for all your help

All Things In Form Text Boxes List Boxes...Saving
Is the a command thats save every thing that is changed changed in form ...all text boxes all list boxes ...everything that has changed

Single Item List Box (item Not Really Selecting)
Application=Access2002

The following code has worked for me in the past but won't now for some reason.
I have a private function and/or subs that performs a few simple operations such as setting listbox rowsources and simple math functions on a form. The queries set as rowsource use criteria from other single item listboxes.
Now, for some reason, the queries won't return values until the previously .selected(0) = true (single item) list boxes have been clicked on.
Problem has only been in creating a new form. Perhaps the problem did not occur in older created forms due to compatibility?


Private Sub fraEWTo_AfterUpdate()

[Edited]
    lstRotorHoursPriorTo.RowSource = "qryRotorSwapHoursTotTo" 'gets hoursprior from tblRotors
    lstRotorHoursPriorTo.Selected(0) = True ' This is one place where the problem seems to exist, the control does not function until it has been clicked on via mouse.

    LstClockInTo.RowSource = "qryRotorSwapRAHoursIPTo"
    LstClockInTo.Selected(0) = True

    txtRACHIPTo.Locked = False
    txtRACHIPTo.Value = txtClockHoursTo.Value - lstClockInTo.Value 'nor will this until the lstClockInTo box has been manually selected


A Mechanic in a Programmers shoes
Thanks




Edited by - greenfch on 12/7/2005 11:22:52 AM

Web Control, List Boxes, Text Boxes, Please Help This Is Winding Me Up!
Hi guys i need some help with the webcontrol function in VB6

Part of my program needs to put listbox data from the program into a text box on the web and then click a submit button...

The list box i have has a list of multiple directories in (for the location of my files), from there i just want the program to put the top directory of the list box into a text box on the web and click a submit button on the web (its for uploading a queue of files), then after that has finished uploading, do the next directory in the list box... etc

It sounds pretty simple but i have no idea how to do it...

Thanks for any help you can give me, i will write a really good review about you and good rating etc.

Any knowledge of this would be greatly appreciated

thanks a bunch

toodle pipples

Alex

How I Can Remove The Last Item?
Hi All
I have list, I add some item now. How to make to remove lately added position however without marking of this position in ListBox. I want to make the statement Undo for the calculation of mathematical. Because in ListBox I display result of every working it then after making Undo I want to clear the last of entry.
thanks in advance

Way To Remove Ini Item
I currently am looking for the best way to remove an item in a .ini file.

Lets say my current .ini file looks like so:
[Area1]
Key1=Text1
Key2=Text2

[Area2]
Key1=Text1
Key2=Text2
Key3=Text3

What if my values change for Area2 and only want one Key. What is the best way to delete Key2 and Key3?

So the result would be:
[Area1]
Key1=Text1
Key2=Text2

[Area2]
Key1=Text1

Thanks in advance.

Remove Item
How do i get a command button to remove the item you are clicked on in a listbox. I know list.removeitem and that is it!

I use to be a scitso but now we are okay

Remove Item From Listbox
Hi

Please can someone help me, here is what i have a 1 textbox and 1 listbox, the listbox is populated from a field in the access database, all good so far. but i need to remove a specific item from the listbox, eg. the listbox is populated with table numbers "Table 1" to "Table 50" the textbox is connected to the database so if i move to "Table 5" in the textbox and click remove it is removed from the database but not from the listbox, so basicall i need to remove a table that i select from the textbox and the corresponding table number in the listbox must be removed, and cant quite figure it out, here is what i am trying.

Private Sub Command1_Click()
Dim MyTest As Integer
MyTest = Text1.Text
List1.RemoveItem MyTest
End Sub

Please can someone give some advise.

Many thanks in advance

Remove Item From Listbox
In the list box, I want to remove selected items and retain the other items in the same positions in which they existed before removal.
For example, consider a listbox having 10 items. Suppose I remove the 7th item, 8th, 9th & 10th items should remain in the same position. 8th to 10th items should not move up in the list. 7th item will not have any values.
How can this be done?

Remove Item From An Array
Is there a function that will remove an item from the middle of an array and redimension the array accordingly? I didn't think so, but before I write a custom function, I wanted to make sure. Thanks.

Remove ListView Item
Hi all,
I am trying to remove a ListView Item. My code doesn't seem to work, could someone please show me where my mistake is. Thanks a bunch.

Code:
Private Sub Command27_Click()

Dim a As Integer

a = GrowthList.SelectedItem.index

GrowthList.ListItems.Remove , , (a) 'This line gives the error

End Sub

Remove Item In Listview
Hello,

I like to remove a selected line only.
I used following code:

Private Sub cmdRemoveCust_Click()
Dim RemError

On Error Resume Next
Err.Clear
lvwAllCustomer.ListItems.Remove (lvwAllCustomer.SelectedItem.Index)

If Err <> 0 Then RemError = MsgBox("No Customer to remove", vbExclamation)


End Sub

When I select a Line in the listview this line will be removed - so far so good :-)
Even I didn't select a line, every time the first line (index 0) will removed when I click the remove_Button.
How can I prevent removing lines which are not selected?

Thanks for help
Stefan

Remove Listbox Item
i know how to remove an item with List1.RemoveItem List1.ListIndex but the list index has to be selected.
is it possible to remove an item without anything selected.

thank you
casey.

Remove Item From Listbox
Well, this is probably easy but I'm stumped and was wondering if I could get some help.

I have a list box that fills with entries from a database.

Now I need to look to see if a particular entry is there and remove it from the list.

For example, if the word "cat" get's loaded into the listbox, find it and remove it.

I tried some code like this but it didn't work.


Code:
Dim b As Integer

For b = 0 To lstHours.ListCount - 1
If lstHours.Text = "11 kach shop time" Then
lstHours.RemoveItem (b)
End If
Next b


now is my code totally off? Does the spaces in the text keep it from working?
Essentially "11 kach shop time" will show up in the list and I want to remove it wherever it shows up and leave all the other items intact.

Remove An Item From A Listbox?
Hey guys I have a listbox called list6, and it has items added to it, now I think you use list6.remove item to take items out. I was wondering by using an if then statement how I would be able to get an item automatically remvoed if it was added.


like if list6.additem = "notepad.exe then
list6.removeitem

end if

thank you!

Remove Item From Listbox
How do I remove an item from a listbox thats on a differant form?

What I have is:

Form1.List1.RemoveItem (List1.ListIndex),

Form3 is a list of names that are also on Form1, when I select a name on Form3 name should be removed from Form1 Listbox also, but its not working.

I get an error, "Invalid procedure or arrgument"

FIY Form3 Listbox is populated by Access db if that means anything

Any thoughts?

Listbox, Remove Item
i have a listbox, with items in it, how do i remove the items one at a time asking yes or no to remove that item. please help as i have been trying of days to do this. thanx

Remove Item From ImageCombo!
I have a ImageCombo which is the address bar in a WebBrowser project. Now if the user sets his home page as about:blank, when the browser loads for the first time, the address bar should show about:blank but if the user clicks the small right arrow (at the extreme right hand side of the ImageCombo) to have a look at the different URLs listed in the address bar, then about:blank shouldn't be listed among the different URLs. How do I accomplish this?

Note that if the home page is not set to about:blank, when the browser loads, that home page URL should be listed as an item when the user clicks the small right arrow to view the URLs listed in the address bar. In other words, only about:blank should never be listed as an item in the address bar; any other URL, be it the home page or not, should be listed in the address bar.

ListView Remove Item!
I need to delete items (one at a time) from a ListView but what is happening is though the selected item gets deleted from the ListView, it leaves a gap between the preceding item & the next item. For e.g. if this is the ListView

India
China
Japan
Chile
Spain

& I delete Chile from the above ListView, Chile gets deleted but it leaves a gap between Japan & Spain i.e. the ListView would now loook like this:

India
China
Japan

Spain

How do I avoid this gap?

Thanks,

Arpan

Remove Item From Txt Document
I'm trying to remove a selected listbox item from a txt file.

The txt file would have data setup as the following:

123456
654321
112233
456455

In my program. I'd like the user to enter a number into the Textbox1 and have them click Command1 to remove the item from the Listbox. So, I'd like the program to:
a) Read the contents of the file
b) Search the txt document for Textbox1.Text
b') If found, remove the item from the txt file..
b'2) If not found, close the file

How would I "search and delete" a string from my txt file?

Thanks! I know this is N00B stuff, and I've tried searching the forums here and found some good info. for reading / writing files, but I just can't seem to get what I need.

Remove Item In Cmbobox
i searched forum and google and still can't get it

how do i get rid of an slelected thing in a combobox
thanks

Remove Array Item
how would i go about removing an item from an array no matter which position the item is in the array.

eg:
arr(0) = "first"
arr(1) = "second"
arr(2) = "third"
arr(3) = "fourth"

how to take say arr(2) out and leave it like this

arr(0) = "first"
arr(1) = "second"
arr(2) = "fourth"

thank you.
casey.

Remove Selected Item
how do i remove the selected item from a listbox?

thanks d00dz.

Remove Listview Item
i found this doing a search on the forum.
it deletes a selected item in a listview but it will also start to delete items from the highest count down without anything selected, can you help me fix this ?

VB Code:
If Not lv.SelectedItem Is Nothing Then  lv.ListItems.Remove lv.SelectedItem.Index End If


thank you
casey.

Listview Remove Item
Hi,

I Have a listview with checkboxes,how can I remove the Items that have been checked from the listview?

thanks

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