Dim i As Integer For i = 1 To 10 'Set label1 = Me.Controls.Add("vb.label", "label1", Me) Set label1 = Me.Controls.Add("vb.label", "i", Me) 我要实现这个效果?怎么做?连续创建十个label 这里 i 是传递过来的,并不想取名叫 i ??? 怎么做啊?
'add a commandbutton whose name is "newbutton"and index is 0,visiable is false
Option Explicit
Private Sub Form_Click()
addcmdline
End Sub
Sub addcmdline()
Me.WindowState = 2
On Error Resume Next
Dim i As Long
For i = 0 To 99
Load newbutton(i)
newbutton(i).Left = (i Mod 10) * 1000 + 1050
newbutton(i).Top = (i \ 10) * 500 + 550
newbutton(i).Caption = "cmd" & i
newbutton(i).Width = 900
newbutton(i).Height = 400
newbutton(i).Visible = True
Next
Me.ForeColor = vbRed
Me.DrawWidth = 3
For i = 0 To 10
Me.Line (1000, 500 + i * 500)-(11000, 500 + 500 * i)
Me.Line (1000 + i * 1000, 500)-(1000 + 1000 * i, 5500)
Next
End Sub
Private Sub newbutton_Click(Index As Integer)
MsgBox " You have clicked " & newbutton(Index).Caption, 64
End Sub