|
ざっくりこんな感じ
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Call Timer1_Tick(sender, e)
Timer1.Interval = 300000 '5分
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
Dim bmp As Bitmap
Dim path As String = "c:\\cg1"
Dim r As New System.Random()
Dim c As Integer
Dim files As String() = System.IO.Directory.GetFiles(path, "*.bmp", System.IO.SearchOption.AllDirectories)
c = r.Next(files.Count)
With PictureBox1
If Not (.Image Is Nothing) Then
.Image.Dispose()
.Image = Nothing
End If
Try
bmp = DirectCast(System.Drawing.Image.FromFile(files(c)), System.Drawing.Bitmap)
Catch ex As Exception
bmp = Nothing
MsgBox("その画像は何やら表示できないみたいです。")
End Try
.Image = bmp
.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
.Visible = True
Application.DoEvents()
.Refresh()
End With
End Sub
End Class
|