在vb.net中,PictureBox图片切换问题。

2024-12-21 04:07:31
推荐回答(2个)
回答1:

1、添加控件Picturebox1和控件Timer1,将Timer1的Interval属性改为1000(即1秒),Enabled属性改为True
2、假设你要循环切换4张图片,你可以添加如下代码即可实现:
Dim a As Integer = 0
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If a = 4 Then
a = 0
Else
a = a + 1
End If
If a = 0 Then Me.PictureBox1.Image = Image.FromFile("1.jpg")
If a = 1 Then Me.PictureBox1.Image = Image.FromFile("2.jpg")
If a = 2 Then Me.PictureBox1.Image = Image.FromFile("3.jpg")
If a = 3 Then Me.PictureBox1.Image = Image.FromFile("4.jpg")
End Sub

回答2:

你应该用timer控件。

interval这个属性设置为1000

图片框 用loadpicture()这个函数

Private Sub Timer1_Timer()
Picture1.Picture=LoadPicture ("C:\1.jpg")
Picture1.Picture=LoadPicture("C:\2.jpg")
Picture1.Picture=LoadPicture("C:\3.jpg")
Picture1.Picture=LoadPicture ("C:\4.jpg")
Picture1.Picture=LoadPicture("C:\5.jpg")
End Sub

像这样吧