加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

vb动态添加和删除PictureBox控件

发布时间:2020-12-16 22:58:15 所属栏目:大数据 来源:网络整理
导读:Option Explicit Private WithEvents NewPicture As PictureBox '通过使用WithEvents关键字声明一个对象变量为新的命令按钮 Private Sub Command1_Click() '这个按钮用来添加新控件 If NewPicture Is Nothing Then Set NewPicture = Controls.Add("VB.Pictur

Option Explicit
Private WithEvents NewPicture As PictureBox
'通过使用WithEvents关键字声明一个对象变量为新的命令按钮

Private Sub Command1_Click() '这个按钮用来添加新控件
If NewPicture Is Nothing Then
Set NewPicture = Controls.Add("VB.PictureBox","picture",Form1)
'增加新的按钮cmdNew
NewPicture.Move 500,500
'确定新增按钮cmdNew的位置
NewPicture.Visible = True
'显示该按钮
End If
End Sub

Private Sub Command2_Click() '这个按钮用来删除新控件If NewPicture Is Nothing Then Exit SubElse Controls.Remove NewPicture Set NewPicture = Nothing End IfEnd SubPrivate Sub NewButton_click() MsgBox "你点击了新建的Picturebox",vbDefaultButton1,"Click"End Sub

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读