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 = "繼續(xù)"
End If
End Sub
End Class