[TUT] C# How to add a Basic Password to Programs

Discussion in 'Archives' started by Fallen Soul, Jul 15, 2008.

[TUT] C# How to add a Basic Password to Programs
  1. Unread #1 - Jul 15, 2008 at 6:47 PM
  2. Fallen Soul
    Joined:
    Mar 11, 2007
    Posts:
    746
    Referrals:
    0
    Sythe Gold:
    0

    Fallen Soul Apprentice

    [TUT] C# How to add a Basic Password to Programs

    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)
    [​IMG]

    Go to your toolbox and add a button, and a textbox to your form.
    [​IMG]

    Double click on your button and it should open up and look like this.
    [​IMG]

    Now add this code...

    Code:
    if (textBox1.Text == ("Jaghax"))
    {
     MessageBox.Show("Correct!");
    }
    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.
    [​IMG]


    Push the start button at the top, or go to Debug > Start debugging
    [​IMG]

    Something like this should popup depending on where you put your buttons and if you named them.

    [​IMG]
    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();
    }
    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
    [​IMG]

    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)
     
< Selling lvl 30 str pure | need mm for pin trade >

Users viewing this thread
1 guest


 
 
Adblock breaks this site