当我想要它时,进度条也不会隐藏? VB

时间:2021-11-11 11:18:57

Hi I am creating a simple game in VB where monsters randomly spawn in and disappear when you click on the picture box several times. Each enemy has a progress bar on top which should disappear when the enemy dies (when the enemies disappear).

嗨我在VB中创建一个简单的游戏,怪物随机产生并在你点击图片框几次后消失。每个敌人的顶部都有一个进度条,当敌人死亡时(当敌人消失时)它会消失。

The code I am trying is as follows:

我正在尝试的代码如下:

    Private Sub Form1...
    progbarstart()
    progbarshow()
    End sub

    Private Sub progbarstart()
    ProgBarEnemy.Visible = false
    End sub

    Private Sub progbarshow()
    If PicBoxEnemy.Visible = true then
    ProgBarEnemy.Visible = true
    Else
    ProgBarEnemy.Visible = false
    End If
    End sub()

I think this all the info you will need there is more code which I think is irrelevant. Thanks in advance.

我认为你需要的所有信息都有更多我认为无关紧要的代码。提前致谢。

1 个解决方案

#1


1  

Look for the VisibleChanged event and put this code in. it will update your progressbar when the picture box is visible or not

查找VisibleChanged事件并将此代码放入。当图片框可见时,它将更新您的进度条

 Private Sub PicBoxEnemy_VisibleChanged(sender As Object, e As EventArgs) Handles PicBoxEnemy.VisibleChanged
        progbarshow()
    End Sub

#1


1  

Look for the VisibleChanged event and put this code in. it will update your progressbar when the picture box is visible or not

查找VisibleChanged事件并将此代码放入。当图片框可见时,它将更新您的进度条

 Private Sub PicBoxEnemy_VisibleChanged(sender As Object, e As EventArgs) Handles PicBoxEnemy.VisibleChanged
        progbarshow()
    End Sub