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  ???怎么做啊?

解决方案 »

  1.   

    创建十个label  建议不要用CONTROLS.ADD,用LOAD控件数组解决,参考下面的代码:
      '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 SubPrivate Sub newbutton_Click(Index As Integer)
    MsgBox " You have clicked " & newbutton(Index).Caption, 64
    End Sub
      

  2.   

    呵呵...可以不断 new 对象呀~
      

  3.   

    建议用load实现控件数组
    for i=0 to 10
    load label1(i)
    label1(i).visable=true
    next i