Computer Science Canada

Message box and Progress Bar Help!

Author:  atal [ Sun Dec 25, 2011 2:07 pm ]
Post subject:  Message box and Progress Bar Help!

code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

TIMER1: ProgressBar1.Increment(25)
BUTTON1: Timer1.Start()

        MessageBox.Show("Message Here", "Title Here")


    End Sub


When ever I debug my program and press the button (Button1) the timer goes but does not finish because the message pops up. How do I make it so that the message pops up after the Progress Bar finishes? Thanks in advance.

Author:  Tony [ Sun Dec 25, 2011 2:38 pm ]
Post subject:  RE:Message box and Progress Bar Help!

The timer is probably non-blocking. It will count something in parallel and maybe fire off some events. Check the documentation on specifics of how it works.

Author:  Night [ Sun Dec 25, 2011 6:49 pm ]
Post subject:  RE:Message box and Progress Bar Help!

I'm not quite sure what you're trying to do, but a couple of ideas based off of your code:

To make it stop once it reaches 100 (or the maximum value of the progress bar):

Add an If statement that checks if the value of the progress bar equals the maximum value of the progress bar. If yes, display the message box.

code:

        If ProgressBar1.Value = ProgressBar1.Maximum Then
            MessageBox.Show("Message Here", "Title Here")
        End If


Do something with the "tick" of the timer: (you'll have to enable it somehow; either via the button or enable it in the properties of the timer)

code:
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        ProgressBar1.Increment(25)
    End Sub


: