我的进度条超过了指定的金额

时间:2015-06-21 17:05:21

标签: vb.net winforms progress

我创建了一个名为poodle doodle的简单程序,你只需单击按钮即可添加到进度条,但是他们可以通过在最大数量上超过1来轻松崩溃程序,但我无法弄清楚如何阻止它执行此操作。我怎么能?

这是我当前的代码

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

1 个答案:

答案 0 :(得分:0)

更改import std.string; void main() { float x = 100 / 3.0; auto s = format("Number: %.*g", 4, x); assert(s == "Number: 33.33"); } 方法以检查该值是否小于100,如下所示:

poodle_Click

你可能想要添加其他逻辑来在玩家获胜时禁用poodle / doodle按钮以及重启游戏的方法。

我不确定您为什么将Private Sub poodle_Click(sender As Object, e As EventArgs) Handles poodle.Click doodle.Visible = True poodle.Visible = False ' This bit If pdb1.Value < 100 Then pdb1.Value += 1 End If End Sub 放在pdb1.Value = pdb1.Value = 0方法中,它应该只是pdb1_Click