Fallen Soul
Apprentice
Well in this tutorial I will teach you how to use an "if statement" to make a very very basic password for your programs.
To start open up your Visual studio and Click Create New Project > Windows form application (Name it what ever you want)
Go to your toolbox and add a button, and a textbox to your form.
Double click on your button and it should open up and look like this.
Now add this code...
This is simply telling your program that if the word "Jaghax" is entered into your textbox , then it should show you the Messagebox.
So far this is what you should have and what it should look like.
Push the start button at the top, or go to Debug > Start debugging
Something like this should popup depending on where you put your buttons and if you named them.
Notice, if you put anything else into the textbox it does nothing. That's cause we haven't told it what to do if something else is put there.
Now we need to tell our program what to do if some one gets the password wrong.
Now we need to tell our program to to do if something else is put in the textbox
Add this right below the last "}" in the "if statement"
This is telling your program to close itself if anything other word is in the textbox other then your set password
It should now look like this
Now open your project again and type in a different word, other then "Jaghax". If you did it right it should instantly close.
This is the end of my tutorial, thank you for reading and if you have any questions or advice please feel free to post it. (I made this myself and I posted it on a different site but felt that it should be released here as well)
To start open up your Visual studio and Click Create New Project > Windows form application (Name it what ever you want)
Go to your toolbox and add a button, and a textbox to your form.
Double click on your button and it should open up and look like this.
Now add this code...
Code:
if (textBox1.Text == ("Jaghax"))
{
MessageBox.Show("Correct!");
}
So far this is what you should have and what it should look like.
Push the start button at the top, or go to Debug > Start debugging
Something like this should popup depending on where you put your buttons and if you named them.
Notice, if you put anything else into the textbox it does nothing. That's cause we haven't told it what to do if something else is put there.
Now we need to tell our program what to do if some one gets the password wrong.
Now we need to tell our program to to do if something else is put in the textbox
Add this right below the last "}" in the "if statement"
Code:
else
{
Application.Exit();
}
It should now look like this
Now open your project again and type in a different word, other then "Jaghax". If you did it right it should instantly close.
This is the end of my tutorial, thank you for reading and if you have any questions or advice please feel free to post it. (I made this myself and I posted it on a different site but felt that it should be released here as well)



