0

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).

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.

  • Sorry I may not have been clear. The progress bar will be invisible to start with. When the enemy spawns I want its coressponding progress bar to spawn with it. And then when the enemy dies I want the progress bar to then disappear. This is then repeated over and over again until the user dies. – hari_prendo Oct 31 '17 at 11:47
  • What is your question? – Nico Schertler Oct 31 '17 at 11:55

1 Answers1

1

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

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