有几件事:如果这些图像不是太大而且太多,您应该考虑预先将它们全部预加载:
Dim images As New List(Of Image)()
images.add(Image.FromFile(Somefilepath))
images.add(Image.FromFile(your2ndFilepath))
' etc.
现在创建一个每 10 秒计时一次的计时器:
Dim pictureChangeTimer As New Timer()
'Creates a timer
AddHandler pictureChangeTimer.Tick, AddressOf pictureChangeTimer_tick
'creates an event handler, simply type in pictureChangeTimer.Tick += and hit tab twice. this will automatically create the method for you
' Sets the timer interval to 10 seconds.
pictureChangeTimer.Interval = 10000
pictureChangeTimer.Start()
现在在一个单独的功能中,您可以在每次活动启动时更改您的图片:
Private Sub pictureChangeTimer_tick(sender As Object, e As EventArgs)
'if using a list
index = (index + 1) Mod images.Count()
pic1.Image = images(index)
'using your original example
'pic1.Image = Image.FromFile("C:\Documents and Settings\IT\My Documents\Downloads\whitehouse.jpg")
End Sub