VB怎样用代码在窗体Form1上画出一个按钮
2个回答
展开全部
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
有任何疑问请追问,满意请采纳,谢谢。
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
有任何疑问请追问,满意请采纳,谢谢。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询