Hey there,
My program works by having a blank form, then adding picturebox controls to the form. I need to reference these pictureboxes later on, and so I need to add each one to part of an array.

But when I am adding my picturebox (The Object) to MyGrid (My Grid), the program crashes saying i have exceeded the boundries of the array.

This is how it looks so far:

    Public Class Form1
    Dim Rows As Integer = 0
    Dim Collumns As Integer = 0
    Dim MyGrid(Rows, Collumns) As PictureBox

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            For Me.Rows = 0 To My.Settings.Rows
            For Me.Collumns = 0 To My.Settings.Collumns

                Dim Seatpicture As New PictureBox
                Seatpicture.Location = New Point(10 + (Collumns * 45), 15 + (Rows * 80))
                Seatpicture.ImageLocation = (My.Settings.Driveletter + ":\Program\Seats\White.gif")
                Seatpicture.SizeMode = PictureBoxSizeMode.StretchImage
                Seatpicture.Size = New Size(40, 78)

                AddHandler Seatpicture.MouseEnter, AddressOf Mouse_Enter
                AddHandler Seatpicture.MouseLeave, AddressOf Mouse_Leave
                AddHandler Seatpicture.MouseClick, AddressOf Mouse_Click

                MyGrid(Rows, Collumns) = Seatpicture
                'This is where the error shows.
                'It works when rows and collumns are (0,0) but when it becomes
                '(0,1), then it shows the error

    End Sub

Can I get any help?
Thanks c:

I just found out, i needed to redefine the Grid to accomadate values Past (0,0)

Be a part of the DaniWeb community

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