Could Someone answer me this?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Could Someone answer me this?

  1. #1
    Join Date
    Jul 2014
    Posts
    1

    Could Someone answer me this?

    Be Massive Help!


    Could someone explain to me each line of the following code of what the code does as well as the overall functionality created:


    string attempt;
    attempt = My_Dialogs.InputBox("Enter your password"); while (attempt != "basic")
    {
    MessageBox.Show("Wrong! - try again.");
    attempt = InputBox("Enter your password"); }
    MessageBox.Show("Welcome to the program!");


    Thanks

  2. #2
    Join Date
    Apr 2014
    Location
    in northeast ohio
    Posts
    49

    Re: Could Someone answer me this?

    this block of code repeatedly prompts the user for a password
    until he enters the exact word "basic"

    the shown calls indicate a winforms application
    or a application that is using system.windows.forms



    // a string that holds the result of what someone types in a textbox
    string attempt;
    // get what the user typed
    attempt = My_Dialogs.InputBox("Enter your password");

    // this will continuously loop until the word "basic" is entered
    // this is read like so...
    // loop while the string variable attempt is not equal !=
    // to the word "basic"
    while (attempt != "basic")
    {

    // display a msg box to the user this is a small pop up that says "wrong try again"
    // this is not a good way to execute this loop there is no way to break out
    // if the user doesn't know the correct word to type
    MessageBox.Show("Wrong! - try again.");
    // this then gets the value from the inputbox that the user will type again
    attempt = InputBox("Enter your password");
    // at this point the program will jump to the while(...) statement and evaluate
    // if it should execute the loop again or continue beyond the end of this bracket
    }
    // after leaving the loop this msg box will be displayed again
    // with the shown messege
    MessageBox.Show("Welcome to the program!");
    Last edited by willmotil; July 23rd, 2014 at 06:56 PM.

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center