2个回答
展开全部
我的是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
组成:一个窗体、一个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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询