Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27351

VS 2010 Re-writing arrays

$
0
0
What I'm trying to do is re-write an array into a list box, changing only a specific index in the array. I know how I would do this in Java, using a for loop and an if statement to change the specific index, but I can't seem to get it to work in Visual Basic

For example, the array is:
Code:

Done
Done
Done

I want to re-write the array to:
Code:

Done
Not done
Done

When a user clicks a button with a specific index.
Code:

                    For l3 = 0 To (SeatBooked.Length - 1) 're-writing the array
                        If l3 = aList.SelectedIndex Then 'if the loop = their selected index
                            SeatBooked(l3) = "Not done" 'that's not done
                        Else
                            SeatBooked(l3) = "Done" 'others done
                        End If
                    Next
                    nList.Items.Clear()
                    For al = 0 To SeatBooked.Length - 1
                        nList.Items.Add(SeatBooked(SeatBooked.Length - 1))
                    Next   
                p = p + 1
                    Return
                End While
            Next
        Next

It doesn't write "Not done" anywhere, it re-writes the array as all "Done"

Viewing all articles
Browse latest Browse all 27351

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>