UKmedia
Programmer
- Nov 2, 2002
- 90
Morning All,
I have a problem with a control array I am setting up to place some buttons on a form but the information like colour, caption, tag reads from a database.
As you can see from the code this is how I asm doing it, proberly not the best way but it does kinda work but gets stuck on
btnButtons(strIndex) = New System.Windows.Forms.Button()
says NullReferenceException was unhandled
any ideas?
UKmedia productions
I have a problem with a control array I am setting up to place some buttons on a form but the information like colour, caption, tag reads from a database.
Code:
Dim strIndex As Short
Dim rs As New ADODB.Recordset()
rs.Open("SELECT * FROM tblButtons", conn)
If rs.EOF Then
Else
Do While Not rs.EOF
rs.MoveFirst()
strIndex = rs.Fields("ButtonID").Value
btnButtons(strIndex) = New System.Windows.Forms.Button()
btnButtons(strIndex).Text() = rs.Fields("Description").Value
btnButtons(strIndex).Tag() = rs.Fields("Price").Value
btnButtons(strIndex).BackColor() = rs.Fields("Colour").Value
btnButtons(strIndex).Size() = New Size(75, 58)
AddHandler btnButtons(strIndex).Click, AddressOf Me.btnButtons_Click
rs.MoveNext()
Loop
End If
'Add control array to the form superclass
Me.Controls.AddRange(btnButtons)
As you can see from the code this is how I asm doing it, proberly not the best way but it does kinda work but gets stuck on
btnButtons(strIndex) = New System.Windows.Forms.Button()
says NullReferenceException was unhandled
any ideas?
UKmedia productions