VB動態產生控制項
Option Explicit
Dim WithEvents cmd1 As CommandButton '宣告若不同控制像宣告該名
Dim mintIndex As Integer
Private Sub Command1_Click()
Dim intLeft As Integer
Dim intTop As Integer
mintIndex = mintIndex + 1
intLeft = 550 * mintIndex '讓產生物件不重疊
intTop = 100 * mintIndex
Set cmd1 = Controls.Add("vb.commandbutton", "button" & mintIndex)
With cmd1
.Visible = True
.Width = 2500
.Height = 500
.Top = 1000 + intLeft
.Left = 1000 + intTop
.Caption = "天然的"
End With
End Sub
0 留言