开发者

How to create var with loop (ex: Dim a1,a2,a3 with loop)

Dim count As Integer
For count = 1 To 10 Step 1
    Dim But+count As New Button
    myButton+count.W开发者_如何学Cidth = 100*count
    myButton+count.Height = 20*count
    myButton+count.Top = 50 *count
    myButton+count.Left = 50*count
    Me.Controls.Add(myButton+count)
Next

Dim But+count As New Button => How to make it work


How about making an array and instantiating the item at the 'ith' position each iteration of the loop. It wouldn't be a1, a2, a3,...; but it would be a[1], a[2], a[3],....


Dim buttons(9) As Button
For count As Integer = 0 To 9
        Dim button As New Button
        button.Width = 100*count
        button.Height = 20*count
        button.Top = 50 *count
        button.Left = 50*count
        Me.Controls.Add(button)
        buttons(count) = button
Next
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜