Results 1 to 5 of 5

Thread: [RESOLVED] Popup yes/no

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    England
    Posts
    79

    Resolved [RESOLVED] Popup yes/no

    How do I make a box prompting the user to answer "yes" or "no" to a question, and how would I handle which result is returned?

    Cheers.

  2. #2
    Frenzied Member ntg's Avatar
    Join Date
    Sep 2004
    Posts
    1,449

    Re: Popup yes/no

    VB Code:
    1. If MessageBox.Show("Text", "Caption", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
    2.             '...said yes
    3.         Else
    4.             '...said no
    5.         End If
    "Feel the force...read the source..."
    Utilities: POPFileDebugViewProcess ExplorerWiresharkKeePassUltraVNCPic2Ascii
    .Net tools & open source: DotNetNukelog4NetCLRProfiler
    My open source projects: Thales SimulatorEFT CalculatorSystem Info ReporterVSS2SVNIBAN Functions
    Customer quote: "If the server has a RAID array, why should we bother with backups?"
    Programmer quote: "I never comment my code. Something that is hard to write should be impossible to comprehend."
    Ignorant quote: "I have no respect for universities, as they teach not practicle stuff, and charge money for"

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    England
    Posts
    79

    Re: [RESOLVED] Popup yes/no

    Solved.

  4. #4
    Hyperactive Member
    Join Date
    Jul 2005
    Posts
    394

    Re: Popup yes/no

    Many ways. Here's a quickie:

    VB Code:
    1. Dim response as DialogResult
    2.  
    3. response = MessageBox.Show("Your message","Your Title", MessageBoxButtons.YesNo)
    4.  
    5. If response = DialogResult.Yes Then
    6.     'Do somthing
    7. End If

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] Popup yes/no

    It may not be the case here, but many people misuse the Yes/No button combination. In the vast majority of cases you should use OK/Cancel. Here are examples of the proper use of the two.

    If the user clicked an Exit button and you displayed a message box asking "Are you sure you want to exit?", the correct buttons to display would be OK and Cancel. OK means "go ahead and do what I asked for" and Cancel means "don't do what I asked for".

    If the user clicked an Exit button and you displayed a message box asking "Do you want to save before exiting?", the correct buttons to display would be Yes and No. Yes means "go ahead and do what I asked for and perform the extra action" and No means "go ahead and do what I asked for but don't perform the extra action". You could also choose to display Yes, No and Cancel, where Yes and No mean the same as above and Cancel means "don't do what I asked for" again.

    There are obviously other situations where Yes and No are appropriate like, if you were to ask "Do you live in the United States?", but when it comes to confirming requested actions, OK and Cancel are more generally the correct choice. In general:

    OK means perform the requested action;
    Yes means perform the requested action plus an additional action;
    No means perform the requested action but not an additional action;
    Cancel means perform no action.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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