急求:VB中在图片框换照片显示的编程

来源:百度知道 编辑:UC知道 时间:2024/06/11 02:11:25
有10张照片,在一个图片框中每2.5秒换一张照片方式的显示```求编程过程!

在一个图片框中每2.5秒换一张照片
要用到TIMER,Picture不用多说

Option Explicit
Dim ind As Integer
Const pp As String = "D:\My Documents\My Pictures\"'照片所在目录
Const pf As String = ".jpg"'照片后缀
Dim fn As String

Private Sub Form_Load()
With Pic
.Top = 0
.Left = 0
End With
ind = 15
Me.Picture = LoadPicture("")
Pic.AutoSize = True
Timer.Enabled = True
End Sub

Private Sub Pic_Resize()
With Pic'窗体居中
Me.Width = .Width
Me.Height = .Height
Me.Top = (Screen.Height - Me.Height) / 2
Me.Left = (Screen.Width - Me.Width) / 2
End With
End Sub

Private Sub Timer_Timer()'换一幅,如果不存在就退出,文件序列不可以有间断
fn = pp & Trim(Str(ind)) & pf
If Dir(fn) = "" Then
Timer.Enabled = False
Unload Me
Else
Pic.Picture = LoadPicture(fn)
ind = ind + 1
End If
End Sub

把它做成GIF再放进去不行吗?