Poppa Mintin
Well-known member
- Joined
- Jan 4, 2018
- Messages
- 45
- Programming Experience
- 10+
Hi,
I'm trying to add some buttons to my Form1:
This code runs twice correctly, then when it gets to...
i = 1
j = 3
num = 3
...I get an error message: "$W0 was Nothing.". The error is at Line 14, line 13 executes ok.
I can't discover what this error means.
Poppa.
I'm trying to add some buttons to my Form1:
Private Sub Buts()
Dim m As Int32 = box \ 6
Dim num As Int32 = 0
Dim naim As String
Dim fnt As New System.Drawing.Font("Comic Sans MS", box \ 4)
For i = 1 To col
For j = 1 To row
num += 1
naim = "Button" & num.ToString
but(num) = CType(Controls(naim), Button)
With but(num)
.Height = box
.Width = box
.Location = spot(num)
.Margin = New Padding(m, m, m, m) '(Left, Top, Right, Bottom)
.BackColor = Color.Transparent
.ForeColor = Color.Black
.Font = fnt
.Text = ""
End With
Me.Controls.Add(but(num))
Next
Next
End Sub
'box' is a global Integer variable, 'spot()' is a global Point variable, both initialised prior to calling this subroutine.This code runs twice correctly, then when it gets to...
i = 1
j = 3
num = 3
...I get an error message: "$W0 was Nothing.". The error is at Line 14, line 13 executes ok.
I can't discover what this error means.
Poppa.