So here's my code. It doesn't work. The Labels do not appear. I've been unable to find my mistake.
For i = 0 To 408 Step 51
Dim text As Integer = 0
Dim label as New Label
Dim name As String = "lbl" + CStr(i)
With label
.Location = New Point(49, 33 + i)
.Size = New Size(32, 32)
.Name = name
.Font = New Font("Microsoft Sans Serif", FontStyle.Bold)
.Text = CStr(text)
.Visible = True
End With
Me.Controls.Add(label)
text += 1
Next
Can someone point it out?
Change the line where you create the font to
.Font = New Font("Microsoft Sans Serif", 12, FontStyle.Bold)
Specify the size otherwise it is defaulting to size 1. Not very visible.
Notice also that you set the text variable to zero at each loop, so all your controls have the same text.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.