完成进度条后,Visual Basic MsgBox未显示

时间:2017-09-09 00:45:08

标签: vb.net visual-studio

我试图在Visual Basic中制作一张宾果卡!

但是有一个问题,每当进度条完成它没有显示MsgBox!

我的代码低于⇣⇣⇣⇣⇣⇣⇣

    Public Class ScamBingo
    Private Sub ScamBingo_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Timer1.Enabled = False
        Timer1.Interval = 100
        ProgressBar1.Maximum = 100
        ProgressBar1.Step = 1
    End Sub

    Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        ProgressBar1.Increment(15.5)
        Timer1.Start()
        Timer1.Stop()
        Button2.Enabled = False
    End Sub

    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        ProgressBar1.Increment(12.5)
        Timer1.Start()
        Timer1.Stop()
        Button8.Enabled = False
    End Sub

    Private Sub ProgressBar1_Click(sender As Object, e As EventArgs) Handles ProgressBar1.Click
        ProgressBar1.Maximum = 100
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If ProgressBar1.Value >= ProgressBar1.Maximum Then
            MsgBox("hi")
            Timer1.Stop()
        End If
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        ProgressBar1.Increment(12.5)
        Timer1.Start()
        Timer1.Stop()
        Button5.Enabled = False
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        ProgressBar1.Increment(12.5)
        Timer1.Start()
        Timer1.Stop()
        Button4.Enabled = False
    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        ProgressBar1.Increment(12.5)
        Timer1.Start()
        Timer1.Stop()
        Button6.Enabled = False
    End Sub

    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        ProgressBar1.Increment(12.5)
        Timer1.Start()
        Timer1.Stop()
        Button7.Enabled = False
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        ProgressBar1.Increment(12.5)
        Timer1.Start()
        Timer1.Stop()
        Button3.Enabled = False
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ProgressBar1.Increment(12.5)
        Timer1.Start()
        Timer1.Stop()
        Button1.Enabled = False
    End Sub
End Class

所以如果有人可以提供帮助,那就太棒了,谢谢:)。

额外信息:

我使用按钮使进度条上升! 我是Visual Basic的新手!

1 个答案:

答案 0 :(得分:0)

Timer1已经停止了所有按钮点击。

 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    ProgressBar1.Increment(12.5)
    Timer1.Start()
    Timer1.Stop()
    Button1.Enabled = False
End Sub

这就是为什么timer1无法调用Timer1_Tick

当进度条达到其停止计时器的最大值时尝试此操作,然后显示MsgBox:

Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Timer1.Enabled = False
    Timer1.Interval = 100
    ProgressBar1.Maximum = 40
    ProgressBar1.Step = 1

End Sub



Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    ProgressBar1.Increment(15.5)
    Timer1.Start()

    Button2.Enabled = False
End Sub

Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
    ProgressBar1.Increment(12.5)
    Timer1.Start()

    Button8.Enabled = False
End Sub

Private Sub ProgressBar1_Click(sender As Object, e As EventArgs) Handles ProgressBar1.Click
    ProgressBar1.Maximum = 100
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    If ProgressBar1.Value >= ProgressBar1.Maximum Then
        Timer1.Stop()
        MsgBox("hi")

    End If
End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
    ProgressBar1.Increment(12.5)
    Timer1.Start()

    Button5.Enabled = False
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
    ProgressBar1.Increment(12.5)
    Timer1.Start()

    Button4.Enabled = False
End Sub

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
    ProgressBar1.Increment(12.5)
    Timer1.Start()

    Button6.Enabled = False
End Sub

Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
    ProgressBar1.Increment(12.5)
    Timer1.Start()

    Button7.Enabled = False
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
    ProgressBar1.Increment(12.5)
    Timer1.Start()

    Button3.Enabled = False
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    ProgressBar1.Increment(12.5)
    Timer1.Start()

    Button1.Enabled = False
End Sub End Class