Private WithEvents NewTextBox As TextBox
創(chuàng)新互聯(lián)建站是一家專注于成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站與策劃設(shè)計(jì),桃源網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)建站做網(wǎng)站,專注于網(wǎng)站建設(shè)10年,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:桃源等地區(qū)。桃源做網(wǎng)站價(jià)格咨詢:18982081108
'通過(guò)使用WithEvents關(guān)鍵字聲明一個(gè)對(duì)象變量為新的命令按鈕
Private Sub Command1_Click()
If NewTextBox Is Nothing Then
Set NewTextBox = Controls.Add("VB.TextBox", "cmdNew", Form1)
NewTextBox.Move 200, 200
NewTextBox.Width = Form1.Width - 450
NewTextBox.Height = Form1.Height - 1400
NewTextBox.Visible = True
End If
End Sub
Private Sub Command2_Click()
If NewTextBox Is Nothing Then
Exit Sub
Else
Controls.Remove NewTextBox
Set NewTextBox = Nothing
End If
End Sub
點(diǎn)擊菜單:項(xiàng)目=》添加引用 彈出窗口后選擇“COM”項(xiàng),然后找到你要加載的控件。
記得先調(diào)用CMD使用 regsvr32 注冊(cè)你準(zhǔn)備加載的控件哈。
Dim?Bt?as?New?Button
Bt.Size=New?Size(100,100)
Bt.Location=New?Point(100,100)
Bt.Text="New?Button"
Me.Controls.Add(Bt)