SUNIL GUTTA

SUNIL GUTTA

  • NA
  • 1k
  • 394.3k

list box issue ??

Dec 5 2013 6:17 AM

        Hi

What I need to be able to do is clear the listbox when clicking other buttons without adding another button specifically to reset it. When btnComp is clicked then the List Box should display what i have in code and etc with other buttons. i know the code to clear the listbox is "lstchosen.items.clear" but it doesnt clear and when i click the other buttons or the same one it just keeps going down the list. without erasing so it may repeat over and over again a numerous amount of times.  ..

Code : 

Public Class frmDepartment
?
?
?
Private Sub btnComp_Click(sender As Object, e As EventArgs) Handles btnComp.Click
If btnComp.Enabled Then
txtSpecific.Text = CStr("Computer Science")
txtNumber.Text = CStr("Number of Majors:8")
End If
If btnComp.Enabled Then
lstChosen.Items.Add("Barbara He")
lstChosen.Items.Add("Michael Dorn")
lstChosen.Items.Add("Julia White")
lstChosen.Items.Add("Jonathan Rubin")
lstChosen.Items.Add("Matthew Singh")
lstChosen.Items.Add("Xiang Fu")
lstChosen.Items.Add("Peter Rosenbaum")
lstChosen.Items.Add("Joann Greenberg")
?
?
End If
?
?
?
?
?
?
End Sub
?
?
?
?
?
?
Private Sub btnIT_Click(sender As Object, e As EventArgs) Handles btnIT.Click
If btnIT.Enabled Then
txtSpecific.Text = CStr("Informational Technology")
txtNumber.Text = CStr("Number of Majors:8")
End If
If btnIT.Enabled Then
lstChosen.Items.Add("John Alexander")
lstChosen.Items.Add("Nicholas Johnson")
lstChosen.Items.Add("Chantel Davidson")
lstChosen.Items.Add("Alex Kaplan")
lstChosen.Items.Add("Vivian Lin")
lstChosen.Items.Add("Amanda Jones")
lstChosen.Items.Add("Elizabeth Lu")
lstChosen.Items.Add("Lauren DeLusso")
Else
If btnComp.Enabled Or btnLiberal.Enabled Then
lstChosen.ClearSelected()
End If
End If
End Sub
Private Sub btnLiberal_Click(sender As Object, e As EventArgs) Handles btnLiberal.Click
If btnLiberal.Enabled Then
txtSpecific.Text = CStr("Liberal Arts")
txtNumber.Text = CStr("Number of Majors:8")
End If
If btnLiberal.Enabled Then
lstChosen.Items.Add("Marilyn Montgomery")
lstChosen.Items.Add("James Martin")
lstChosen.Items.Add("Susan DeLillo")
lstChosen.Items.Add("John Nelson")
lstChosen.Items.Add("Jeri Heckman")
lstChosen.Items.Add("John Page")
lstChosen.Items.Add("Janes Padavano")
lstChosen.Items.Add("Vinny Batista")
Else
If btnComp.Enabled Or btnIT.Enabled Then
lstChosen.ClearSelected()
End If
End If
End Sub

Ty for ur help friend 

Answers (1)