The idea is to select a genre from a listbox and press a button and the program performs a lookup of the array to display the aisle number according to the genre.
I need to use the listbox SelectedIndex property to find the aisle number.
This is what I have so far.
I want to understand how to do this and WHY it works rather than just an answer, although one would be appreciated..
I have struggled with Arrays in programming for years and if I don't figure it out I may get burned out.
I have the form/gui all done I am having problems with the code.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tabledata(5, 2) As String
tabledata(0, 0) = ("Aisle 1")
tabledata(1, 0) = ("Aisle 2")
tabledata(2, 0) = ("Aisle 3")
tabledata(3, 0) = ("Aisle 4")
tabledata(4, 0) = ("Aisle 5")
tabledata(5, 0) = ("Back Wall")
''''''''''''''''''''''''''''''''''''''
tabledata(0, 1) = ("Comedy")
tabledata(1, 1) = ("Drama")
tabledata(2, 1) = ("Action")
tabledata(3, 1) = ("Sci-Fi")
tabledata(4, 1) = ("Horror")
tabledata(5, 1) = ("New Releases")
'''''''''''''''''''''''''''''''''''''''
tabledata(0, 2) = (0)
tabledata(1, 2) = (1)
tabledata(2, 2) = (2)
tabledata(3, 2) = (3)
tabledata(4, 2) = (4)
tabledata(5, 2) = (5)
Dim genre As String
genre = ListBox1.SelectedItem
If genre = tabledata(0, 1) Then
Label1.Text = tabledata(0, 0)
End If
End Sub
End Class


Sign In
Create Account


Back to top









