如何用VB实现幻灯片

来源:百度知道 编辑:UC知道 时间:2024/06/22 00:34:26
要求不用按钮 每隔10秒自动播放下一张图片

至于图片切换的方式 不要求

放一个timer,timer的interval=1000,放置一个filebox,visible=false,一个picturebox.
dim paths() as string
dim ImagePath as string

private sub Form_Load()
dim i as integer
imagepath = app.path
picture1.left = 0
picture1.top =0
picture1.width = width
picture1.height = height
picture1.borderstyle = 0
file1.visible = false
file1.path = imagepath '图片路径设在程序所在路径
file1.pattern="*.bmp;*.jpg;*.gif;*.jpeg"
redim preserve paths(file1.listcount)
for i = 0 to file1.listcount
paths(i) = file1.list(i)
next
end sub

private sub Timer1_Timer()
static i as integer
static j as integer
if i = 10-1 then '10秒
if j > file1.listcount then j = 0
picture1.picture = loadpicture(imagepath & "\" & paths(j))
j = j + 1
i = 0
else
i = i + 1
end if
end sub