none
how to show message box only once in vb.net

    Question

  • I created a form with timer which alerts for every 10 seconds. In that i used the message box to show the alert message. It alerts me every 10 seconds and if i dont check the message box it start showing so many message box. i want it to alert or show only once and wait for my check. please help me..........
    Thursday, February 09, 2006 11:25 AM

All replies

  • One way which springs to mind is to use a boolean (either static or at form level). When you show the messagebox set the boolean to true. When the messagebox is closed set the boolean to false. And everytime you're about to display the messagebox, check first if the boolean is false. To establish when the messagebox is closed use the dialog result.

    If MessageBox.Show("...") = DialogResult.OK Then
        dialogShown = False
    End if
    (or something to that effect)

    You might not even need the boolean, depending on how you've used things.

    You could also switch off the timer, and only restart it when the dialog is closed, if appropriate.

    Thursday, February 09, 2006 12:27 PM