📄 动态增减控件.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3645
ClientLeft = 60
ClientTop = 345
ClientWidth = 5175
LinkTopic = "Form1"
ScaleHeight = 3645
ScaleWidth = 5175
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "删除控件"
Height = 315
Left = 1560
TabIndex = 1
Top = 1680
Width = 1275
End
Begin VB.CommandButton Command1
Caption = "增加控件"
Height = 315
Left = 1560
TabIndex = 0
Top = 1020
Width = 1275
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private WithEvents newbutton As CommandButton
Attribute newbutton.VB_VarHelpID = -1
Private Sub Command1_Click()
If newbutton Is Nothing Then
Set newbutton = Controls.Add("VB.CommandButton", "CmdNew")
newbutton.Move Command1.Left + Command1.Width + 240, Command1.Top
Controls("CmdNew").Caption = "动态控件"
Form1(2).Visible = True
End If
End Sub
Private Sub Command2_Click()
If Not (newbutton Is Nothing) Then
Controls.Remove newbutton
Set newbutton = Nothing
End If
End Sub
Private Sub newbutton_Click()
MsgBox "您点击了动态增加的按钮"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -