Results 1 to 8 of 8

Thread: Message Box that allows user intervention

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Message Box that allows user intervention

    I'm doing some code testing where I use a MsgBox to show some info about the current status of a particular function. The problem I have with MsgBox is I have no way to intervene or interrupt it to do some manual stuff at any given point that I need to do so as it blocks me from doing any other action.

    How can I have a MsgBox that will allow me to stop it when necessary then continue on


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,218

    Re: Message Box that allows user intervention

    Not sure what you are asking here. What do you mean by
    How can I have a MsgBox that will allow me to stop it when necessary then continue on
    msgbox is modal, if you want something none modal then don;t use a message box. Use a form of your own making.

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,215

    Re: Message Box that allows user intervention

    Vista & above can use TaskDialog API to create a self-closing dialog. The MessageBox API can be shown non-modally which means it doesn't block code execution. Maybe a message box is the wrong option here, maybe a status-bar like option is better?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,165

    Re: Message Box that allows user intervention

    What's wrong with Debug.Print and Stop (or IDE breakpoints)?

    You can also just show a custom Form non-modally if this isn't IDE debugging.

  5. #5
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,057

    Re: Message Box that allows user intervention

    Quote Originally Posted by LaVolpe View Post
    Vista & above can use TaskDialog API to create a self-closing dialog.
    Quote Originally Posted by MountainMan View Post
    The code below is a replacement for MsgBox ... It uses an undocumented function for an optional timeout period that has been around since XP (theoretically it could go away but unlikely since it is still in as of 8.1).
    See also MessageBoxTimeout API.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  6. #6
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,039

    Re: Message Box that allows user intervention

    Quote Originally Posted by dilettante View Post
    What's wrong with Debug.Print and Stop (or IDE breakpoints)?

    You can also just show a custom Form non-modally if this isn't IDE debugging.
    Yeah, I've been debugging in VB for 24 years and have never used a msgbox even once. It makes no sense to use one in the IDE.

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,218

    Re: Message Box that allows user intervention

    Yes, debug.print makes much more sense for debugging purposes. Log files also can be handy especially when not in the IDE.

  8. #8
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    2,546

    Re: Message Box that allows user intervention

    If this was an end-user thing or you just wanted the experience, I'd use TaskDialogIndirect. You can have a progress bar and text fields updated by the program, and set buttons not to close the box when clicked so you can send commands back. It would be a little much just for debugging tho.

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