Imports System.Collections.ObjectModel
Public Class 别人的图片播放器
Dim pause As Boolean = False
Public Sub Delay(ByVal mSec As Long)
On Error Resume Next
Dim TStart As Long
TStart = Now.Ticks / 10000
While (Now.Ticks / 10000 - TStart) < mSec
Application.DoEvents()
End While
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim files As ReadOnlyCollection(Of String)
files = My.Computer.FileSystem.GetFiles("D:\我的图片\逃离无名岛", FileIO.SearchOption.SearchAllSubDirectories, "*.*")
For i As Integer = 0 To files.Count - 1
Do While pause = True
Delay(1000)
Loop
Try
Me.PictureBox1.Image = System.Drawing.Image.FromFile(files(i))
Delay(1 * 2000) '两幅图之间的显示间隔
Catch ex As Exception
End Try
Application.DoEvents()
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
pause = Not pause
If pause = False Then
Me.Button2.Text = "暂停"
Else
Me.Button2.Text = "继续"
End If
End Sub
End Class