I have 2 listboxes, a command button and a textbox in a form.
for "training" purposes, both list boxes are filled with the numbers 1 - 10.
I wish to change the value of one of the items in the listbox and replace it with the value of the text box.
The code i've produced below doesnt work as expected.
the msgbox displays the listindex which is correct
the item is removed from the listindex which is also correct.
however, when the value of the textbox or "none" is added back into the listbox, the item is added at the bottom of the list instead of the place where the 1st item was removed.
Private Sub CommandButton1_Click() Dim lnx As Integer Dim plc As String MsgBox ListBox2.ListIndex lnx = ListBox2.ListIndex ListBox2.RemoveItem ListBox2.ListIndex If TextBox1.Text = "" Then plc = "None" ListBox2.AddItem plc ListBox2.ListIndex = lnx Else ListBox2.ListIndex = lnx ListBox2.AddItem TextBox1.Text End If
Thanks in advance KG87

Start a new topic
Add Reply






MultiQuote
| 


