Public Class videoBonanzaForm

    Dim videoBonanza(,) As String = {{"Comedy", "Aisle 1"}, {"Drama", "Aisle 2"}, {"Action", "Aisle 3"}, _
                                      {"Sci-Fi", "Aisle 4"}, {"Horror", "Aisle 5"}, {"New Releases", "Back Wall"}}

    Private Sub videoBonanzaForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub searchButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles searchButton.Click
        If categoriesListBox.SelectedIndex = -1 Then
            MessageBox.Show("No Category Selected!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1)
        Else
            aisleLabel.Text = videoBonanza(categoriesListBox.SelectedIndex, categoriesListBox.SelectedIndex)
        End If
    End Sub
End Class

I get an error at the Else statement during run time. Why can I not access the element this way?

You problem is your array is 2 wide. When you get to an index of 3 your code is trying to read a(1,2,3)
Do this instead:

aisleLabel.Text = videoBonanza(categoriesListBox.SelectedIndex, 0)
- or -
            aisleLabel.Text = videoBonanza(categoriesListBox.SelectedIndex, 1)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.