listbox add and remove

theazza

Member
Joined
May 20, 2011
Messages
23
Programming Experience
1-3
each time i want to add a name into the listbox from another listbox when clicking the button it warks but if a try again that name removes itself and is replaced by the new name how do you prevent this and have name from one lisbox add to the other without deleting the previously added name whilst remove the name from the other list box



Dim updatedSession, i As Integer
updatedSession = lstSessions.SelectedIndex
Dim changed As String = lstNames.SelectedItem
'reads all the names in a particular text file and displays them in the listbox, except for the first first 3 lines
Dim reader As StreamReader = File.OpenText(FileNames(updatedSession))
If lstupdate.Items.Count = 10 Then
MsgBox("Each lesson may only have 10 students")
End If
lstupdate.Items.Clear()
i = 0
Do While reader.Peek <> -1
If (i > 2) Then
lstupdate.Items.Add(reader.ReadLine())
Else
reader.ReadLine()
End If
i += 1
Loop
reader.Close()
lstNames.Items.Remove(changed)
lstupdate.Items.Add(changed)
 
Back
Top