在VB中设置图像

时间:2014-08-06 21:57:59

标签: vb.net image picturebox

好的,所以我试图制作一个加载屏幕,点亮六个点,然后重置,直到完成加载。前两个点改变图片,但第三个不改变!我该如何解决!我的代码:

If picbox1.image is image1 then
  picbox1.image = image 2
ElseIf picbox1.image is image 2
  picbox2.image = image 2
ElseIf picbox2.image is image 2
  picbox3.image = image 2

这都在计时器内,间隔为1000(1秒)

以下是我的项目文件:https://www.dropbox.com/s/v4qf8zlyrz1616s/The%20Eye%20OS.zip

1 个答案:

答案 0 :(得分:0)

只需添加" Not"在Elseifs之后

If picbox1.image is image1 then
 picbox1.image = image 2
ElseIf Not picbox2.image is image 2
 picbox2.image = image 2
ElseIf Not picbox3.image is image 2
 picbox3.image = image 2
'So on
End If

我检查了你的项目,这是下面的完整解决方案:

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    If Dot1.Image Is UnDot Then
        Dot1.Image = LoDot
    ElseIf Not Dot2.Image Is LoDot Then
        Dot2.Image = LoDot
    ElseIf Not Dot3.Image Is LoDot Then
        Dot3.Image = LoDot
    ElseIf Not Dot4.Image Is LoDot Then
        Dot4.Image = LoDot
    ElseIf Not Dot5.Image Is LoDot Then
        Dot5.Image = LoDot
    ElseIf Not Dot6.Image Is LoDot Then
        Dot6.Image = LoDot
    Else
        Dot1.Image = UnDot
        Dot2.Image = UnDot
        Dot3.Image = UnDot
        Dot4.Image = UnDot
        Dot5.Image = UnDot
        Dot6.Image = UnDot
    End If
End Sub