Why doesn't this code work? i want the program to go through each listbox item and give a value to the lstbox() array so that i know which items are selected. If lstbox() = 0 then that item wasnt selected. If lstbox() = 1 then item was selected.

Code:
        lstbox(0) = 0 
        lstbox(1) = 0 
        lstbox(2) = 0 
        lstbox(3) = 0 
        lstbox(4) = 0 
        lstbox(5) = 0 
        lstbox(6) = 0 
        lstbox(7) = 0 
        lstbox(8) = 0 
        lstbox(9) = 0 

        Dim n As Integer = 0 
       
        If listbox.SelectedIndex = -1 Then 
            elephant += 1 
        Else 
            Do 
                If listbox.Items(n) = listbox.SelectedIndex Then 'if client is selected then add a value to array 
                    lstbox(n) = 1 
                Else 
                    lstbox(n) = 0 
                End If 
                n += 1 
            Loop Until n = 10 
        End If
Please help!