vb动态添加image控件!
我想在类模块中封存该image控件数组的属性,如picture···属性可是怎么写代码?怎么调用这些属性并添加到窗体?我是这样的:‘class1中dimimage()as...
我想在类模块中封存该image控件数组的属性,如picture···属性
可是怎么写代码?怎么调用这些属性并添加到窗体?
我是这样的:
‘class1中
dim image() as image
image.picture=loadpicture (app.path+"\123.gif")
但是怎么调用并 load image(i) 展开
可是怎么写代码?怎么调用这些属性并添加到窗体?
我是这样的:
‘class1中
dim image() as image
image.picture=loadpicture (app.path+"\123.gif")
但是怎么调用并 load image(i) 展开
2个回答
展开全部
有两种方法。
方法一:
向在窗体上添加一个image1控件,在属性窗口中将其Index属性设置为0(就是定义一个图像框控件数组),然后用下面代码:
Private Sub Command1_Click()
Load Image1(1)
With Image1(1)
.Stretch = True
.Picture = Image1(0)
.Top = 100
.Left = 100
.Visible = True
End With
Load Image1(2)
With Image1(2)
.Picture = Image1(0)
.Top = 100
.Left = 2000
.Visible = True
End With
End Sub
方法二:
Private Sub Command1_Click()
For i = 1 To 4
BqName = "Image" & i
Set Newlbl = Controls.Add("VB.image", BqName)
Newlbl.Move 3500, 500 * i, 1000, 360
Newlbl.Stretch = True
Controls(BqName).Picture = LoadPicture("D:\My Documents\My Pictures\a.jpg")
Newlbl.Visible = True
Next i
End Sub
更多VB代码可参阅我的博客:http://hi.baidu.com/zgmg/blog/item/3768b7efc1f540f1ce1b3ea8.html
方法一:
向在窗体上添加一个image1控件,在属性窗口中将其Index属性设置为0(就是定义一个图像框控件数组),然后用下面代码:
Private Sub Command1_Click()
Load Image1(1)
With Image1(1)
.Stretch = True
.Picture = Image1(0)
.Top = 100
.Left = 100
.Visible = True
End With
Load Image1(2)
With Image1(2)
.Picture = Image1(0)
.Top = 100
.Left = 2000
.Visible = True
End With
End Sub
方法二:
Private Sub Command1_Click()
For i = 1 To 4
BqName = "Image" & i
Set Newlbl = Controls.Add("VB.image", BqName)
Newlbl.Move 3500, 500 * i, 1000, 360
Newlbl.Stretch = True
Controls(BqName).Picture = LoadPicture("D:\My Documents\My Pictures\a.jpg")
Newlbl.Visible = True
Next i
End Sub
更多VB代码可参阅我的博客:http://hi.baidu.com/zgmg/blog/item/3768b7efc1f540f1ce1b3ea8.html
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询