Hi
I need help with the highlighted part at the very bottom.
The highlighted part is the code for the "View Information Button"
The problem is, when I choose bus 500 from combo box, the code works fine and shows last four names of passenger array. That's how it is supposed to be.
but then when I choose bus 400, it shows last 8 names plus last four names again, while it is supposed to show only 4 names of second last element of array.
just like when I choose bus 100, it shows all the names of passenger array, while it is supposed to show only first 4 names of the passenger array.
Here is what I have:
Public Class BusReservationForm
Dim destination As String(,) = {
{"12/23/2013", "Atlanta", "Houston"},
{"12/11/2013", "San Francisco", "New York"},
{"12/24/2013", "Seattle", "Miami"},
{"1/12/2014", "Las Vegas", "Chicago"},
{"2/9/2014", "Boston", "Miami"}
}
Dim bus As Integer = 0
Dim passenger As String(,) = {
{"Tim Pedan", "Frank Maxwall",
"Roger Gange", "Kevin Conrad"},
{"Filomina Sylva", "Moe Hernandez",
"Jon Flowers", "John Hathaway"},
{"Brian Alban", "Chris Blaha",
"Simon Hoyle", "Carol Coggins"},
{"Bill Raynolds", "Ronny Jenkins",
"Sheena Jenkins", "Ayu Johnson"},
{"Darryl Jackson", "Sean Byfield",
"Caroline Litchfield", "Leigh Oats"}
}
Dim list As Integer = 0
Private Sub BusReservationForm_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
busChoiceComboBox.Items.Insert(0, "100")
busChoiceComboBox.SelectedItem = "100"
busChoiceComboBox.Items.Add("200")
busChoiceComboBox.Items.Add("300")
busChoiceComboBox.Items.Add("400")
busChoiceComboBox.Items.Add("500")
End Sub ' BusReservationForm_Load
Private Sub busChoiceComboBox_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles busChoiceComboBox.SelectedIndexChanged
Select Case busChoiceComboBox.SelectedIndex
Case 0
bus = 0
Case 1
bus = 1
Case 2
bus = 2
Case 3
bus = 3
Case 4
bus = 4
End Select
' display info
dateOutputLabel.Text = destination(bus, 0)
departOutputLabel.Text = destination(bus, 1)
arrivalOutputLabel.Text = destination(bus, 2)
End Sub
Private Sub busInfoButton_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles busInfoButton.Click
For row As Integer = 0 To passenger.GetUpperBound(0)
For column As Integer = 0 To passenger.GetUpperBound(1)
displayListBox.Items.Add(passenger(row, column))
Next column
Next row
End Sub
End Class

displayListBox.Items.Clear() i kept and tried ..... still issue exists .. can u please edit my code so works fine
My best regards
Sunil G

FroglegPosted Dec 9, 2013, 1:58 AM
Private Sub busInfoButton_Click(sender As System.Object, e As System.EventArgs) Handles busInfoButton.Click
ListBox2.Items.Clear()
For i As Integer = 0 To passenger.GetUpperBound(1)
ListBox2.Items.Add(passenger(bus, i))
Next
End Sub
SUNIL GUTTAPosted Dec 11, 2013, 6:46 AM
SUNIL GUTTAPosted Dec 8, 2013, 11:22 PM
Mahesh ChandPosted Dec 8, 2013, 11:14 PM
You don't need to format text and make it all bug and bold. It makes it less readable. Just type your question in the editor.
Thanks
SUNIL GUTTAPosted Dec 8, 2013, 10:20 PM
Please can u try to dynamic acc to needs frnd
FroglegPosted Dec 6, 2013, 2:35 PM
Private Sub busInfoButton_Click(sender As System.Object, e As System.EventArgs) Handles busInfoButton.Click
ListBox2.Items.Clear()
For i As Integer = 0 To 3
displayListBox.Items.Add(passenger(bus, i))
Next
End Sub