[vb]代码库
Option Explicit
Dim WithEvents cmdSayHello As CommandButton
Dim WithEvents cmdClose As CommandButton
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdSayHello_Click()
MsgBox "Hello world!", vbInformation, Me.Caption
End Sub
Private Sub Form_Load()
Set cmdSayHello = Me.Controls.Add("VB.CommandButton", "cmdSayHello")
With cmdSayHello
.Left = 4000
.Top = 250
.Width = 1200
.Height = 350
.Caption = "&Say Hello"
.Visible = True
End With
Set cmdClose = Me.Controls.Add("VB.CommandButton", "cmdClose")
With cmdClose
.Left = 4000
.Top = 700
.Width = 1200
.Height = 350
.Caption = "&Close"
.Visible = True
End With
End Sub