Private Sub Form_Load()
Set Img = Controls.Add("VB.Image", "img")
With Img
.Visible = True
.Width = 2000
.Top = 0
.Left = 0
.Picture = LoadPicture("e:\照片 026.jpg")
End With
End Sub
这样可以无中生有
用.net编码:
1、动态生成20个image控件
……
dim i as integer
for i=0 to 19
dim image_X as new image()
with image_X
.top=i*100 +44 '设定控件在窗体上的排放位置
.left=20
……
end with
me.controls.add(image_x) '这个语句非常重要,他把生成的image_x控件添加到当前的窗体中
next
……
2、动态抽取图片
用随机述:
dim ran1 as new random()
dim ran2 as new random()
dim i as integer
dim j as integer
i=ran1.next(1,10) ‘在1到10之间产生一个随机数
j=rand2.next(1,20) ‘在1到20之间产生一个随机数
for k=0 to i-1
……
next
for kk=0 to j-1
……
next
3、如有不明白之处请回复。