I created a simple program called poodle doodle where you just click buttons to add to a progress bar but they could easily crash the program by just going 1 over the max amount but i cant figure out how to stop it from doing that. How can I?
Here's my current code
Public Class Form1
Private Sub poodle_Click(sender As Object, e As EventArgs) Handles poodle.Click
doodle.Visible = True
poodle.Visible = False
pdb1.Value = pdb1.Value + 1
End Sub
Private Sub doodle_Click(sender As Object, e As EventArgs) Handles doodle.Click
poodle.Visible = True
doodle.Visible = False
End Sub
Private Sub pdb1_Click(sender As Object, e As EventArgs) Handles pdb1.Click
If pdb1.Value = 100 Then
MessageBox.Show("You Poddled And Doodled To Victory!", "Poodle Doodle Champion")
pdb1.Value = pdb1.Value = 0
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
pdb1.Maximum = TextBox1.Text
End Sub
Change the
poodle_Click
method to check that the value is less than 100 like this:You'll probably want to add other logic to disable the poodle/doodle buttons when the player wins and a way to restart the game.
I'm not sure why you put
pdb1.Value = pdb1.Value = 0
in thepdb1_Click
method, it should just bepdb1.Value = 0
.