Listboxes and Loops

  • Thread starter Thread starter mightymagi82
  • Start date Start date
M

mightymagi82

Guest
Hey everyone, right now I'm on a visual basic assignment where I have two listboxes with Workshops in the first and Locations in the second. I'm having some issues trying to figure out first how to make a variable that will store whatever the selections are in each of the two listboxes, then I'm also needing to make a loop that will allow me to go through each combination of the two listbox selection combinations so I can make a calculation on some prices for each combination without having to type out repetitious code for each of these selections. here's an example of what I started with:

Private Sub btnAddWorkshop_Click(sender As Object, e As EventArgs) Handles btnAddWorkshop.Click
If lstWorkshop.SelectedIndex = -1 Then
MessageBox.Show("Please select a workshop from the list", "Workshop Error")
Exit Sub
ElseIf Do While lstWorkshop.SelectedIndex = 0 To 4 Then
If lstLocation.SelectedIndex = -1 Then
MessageBox.Show("Please select a location from the list", "Location Error")
Exit Sub
ElseIf Do While lstLocation.SelectedIndex = 0 To 4 Then
decLodging = dec_AUSTIN * int_STRESS
strWorkshop = "Handling Stress"
strLocation = "Austin"
lstCosts.Items.Insert(0, "Workshop: " & strWorkshop)
lstCosts.Items.Insert(1, "Location: " & strLocation)
lstCosts.Items.Insert(2, "Lodging: " & decLodging.ToString("C"))
lstCosts.Items.Insert(3, "Workshop Fee: " & dec_STRESS.ToString("C"))
lstCosts.Items.Insert(4, "")

Continue reading...
 
Back
Top