-
July 23rd, 2014, 05:58 PM
#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
-
July 23rd, 2014, 06:35 PM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|