我要做一个用vb编写的图片浏览器,怎样使用定时器控件使其每间隔1000毫秒,就自动显示下一张图片??? 5

一定要有代码!!也就是能自动播放... 一定要有代码!!
也就是能自动播放
展开
 我来答
Zaxife
2011-03-10 · TA获得超过1254个赞
知道小有建树答主
回答量:1138
采纳率:0%
帮助的人:411万
展开全部
我的是VS2010的VB.Net,已经调试通过。
组成:一个窗体、一个PictureBox控件、一个ListBox控件、一个Timer控件
作用:把我的文档中图片文档的所有jpe和gif图片加载到ListBox控件中,然后Timer控件就每隔一秒读取ListBox中的图片路径文件名列表显示到PictureBox上。

代码:
Public Class Form1
Dim PicIndex As Long
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.ListBox1.Items.Clear()
Me.PictureBox1.ImageLocation = ""
For Each foundImage As String In _
My.Computer.FileSystem.GetFiles( _
My.Computer.FileSystem.SpecialDirectories.MyPictures, _
FileIO.SearchOption.SearchTopLevelOnly, "*.gif*", "*.jpg*")
Me.ListBox1.Items.Add(foundImage)
Next
If Me.ListBox1.Items.Count < 1 Then
MsgBox("There are no JPEG or GIF images in" _
& " the Picture folder.")
End If
Me.PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Me.PictureBox1.ImageLocation = Me.ListBox1.SelectedItem
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If ListBox1.Items.Count < 1 Then Exit Sub
If PicIndex < ListBox1.Items.Count Then
Me.PictureBox1.ImageLocation = ListBox1.Items(PicIndex)
Me.Text = "当前图片路径和文件名: " & ListBox1.Items(PicIndex)
PicIndex = PicIndex + 1
Else
PicIndex = 0
End If
End Sub
End Class
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
沙慧月03
2011-03-10 · TA获得超过2154个赞
知道大有可为答主
回答量:2717
采纳率:100%
帮助的人:3573万
展开全部
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Form_Load()

Timer1.Enabled = False
Timer1.Interval = 1000
File1.Path = "D:\Backup\我的文档\My Pictures"
File1.ListIndex = -1
End Sub

Private Sub Timer1_Timer()

If File1.ListIndex <= File1.ListCount - 1 Then
File1.ListIndex = File1.ListIndex + 1
Image1.Picture = LoadPicture(File1.Path & "\" & File1.FileName)
Else
Timer1.Enabled = False
MsgBox "over"
End If
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式