Results 1 to 3 of 3

Thread: Confusing DoEvents problem [RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575

    Confusing DoEvents problem [RESOLVED]

    Hi,

    I have a program that processes something, then displays a messagebox giving the results.

    Now, as soon as the user clicks the okay button on the messagebox, i want the application to end.

    The way I have done that is this way:
    VB Code:
    1. MsgBox("Done", MsgBoxStyle.Information, "Complete")
    2.             Application.Exit()
    However I have found that it just seems to exit the application the second it puts the messagebox up. It doesn't wait for the user to press the okay button. I think this is because of the
    "Application.DoEvents()" I put at the start of the sub. The problem is tho, i need this for it to show the message box at all. I dunno why, but it's the way i've coded it - very weirdly!!!

    So is there a way to make the code just wait for the user to press the okay button on the message box before it processes the application.exit() ?

    Thanks very much! I've tried lots of things but nothing seems to work. I either get the messagebox to popup, but the program doesnt end when u press okay. or the current situation where it doesn't come up at all and just ends.
    Last edited by LITHIA; Jul 20th, 2004 at 09:40 AM.

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    HI,

    I've tried but cannot duplicate your result, even with Application.DoEvents in the procedure so I think there must be something else. However, try

    VB Code:
    1. If MsgBox("Done", MsgBoxStyle.Information, "Complete") = MsgBoxResult.OK Then
    2.             Application.Exit()
    3.         End If

    If that does not work for you then I suggest you post your sub.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  3. #3

    Thread Starter
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575
    thanks, i managed to fix it.

    i changed the order if which it closed a form. no idea why that altered the messagebox tho.

    i think your code helped though, i'm keeping it in.

    thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width