C
Confessor
I've heard that 'brevity is the ultimate bugkiller,' and I can't help but
feel that portions of my code could be a bit more brief.
I have 85 different labels comprising a type of 'gameboard.'
Upon initialization in the code generated by the form designer, each
label receives properties as follows.
Me.Labelx.BackColor = System.Drawing.Color.White
Me.Labelx.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Labelx.Location = New System.Drawing.Point(x, y)
Me.Labelx.Name = "Labelx"
Me.Labelx.Size = New System.Drawing.Size(32, 32)
Me.Labelx.TabIndex = x
As you might expect, only the TabIndex, Name, and Location properties
vary per label. If anybody can tell me how to make it so I can set the
three static properties only *once* for all eighty-five labels, that
would probably save me ~200 lines of code right there.
Similarly, specific events/procedures scattered throughout the program
modify all 85 gameboard labels in the same way. Currently, I have to do
something like this:
Label1.Text = ""
For all 85 labels...
Or, when I pass label status to my variables for in-depth analysis, I
currently have to
Tile(1).Color = Label1.BackColor
For all 85 labels.
Any help would be appreciated.
feel that portions of my code could be a bit more brief.
I have 85 different labels comprising a type of 'gameboard.'
Upon initialization in the code generated by the form designer, each
label receives properties as follows.
Me.Labelx.BackColor = System.Drawing.Color.White
Me.Labelx.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.Labelx.Location = New System.Drawing.Point(x, y)
Me.Labelx.Name = "Labelx"
Me.Labelx.Size = New System.Drawing.Size(32, 32)
Me.Labelx.TabIndex = x
As you might expect, only the TabIndex, Name, and Location properties
vary per label. If anybody can tell me how to make it so I can set the
three static properties only *once* for all eighty-five labels, that
would probably save me ~200 lines of code right there.
Similarly, specific events/procedures scattered throughout the program
modify all 85 gameboard labels in the same way. Currently, I have to do
something like this:
Label1.Text = ""
For all 85 labels...
Or, when I pass label status to my variables for in-depth analysis, I
currently have to
Tile(1).Color = Label1.BackColor
For all 85 labels.
Any help would be appreciated.