Let's Jump Right Into It...
Lets say you already have a fully working program and just want to add it that you need a password to lets say 'Activate' it. Without having to add a seperate form that starts at the begining...
You could do some thing like this
Goto your Form1.load and add something like
button1.Enabled = false;
And keep doing that till you disable every thing on start up, and then have a textbox and a button that checks if the password is correct then every thing will be re-enabled by doing
button1.Enabled = true;
You should be able to know that from doing what I am about to show...
This is going to be a loginscreen before your program starts
Start off by adding a Button and a Textbox.
Lets add a string...
Now a bit of this... (Don't worry pictures at the end)
Add that stuff in the button1_Click -> This can be done by double clicking the button...
password = textBox1.Text;
Now the first part.. Check if they even bothered to type some thing in
Basically if textbox1 is left blank, prompt this message
if (password == "")
MessageBox.Show("Ha you forgot to type in st00f");
But what if they typed the correct password?
What this means is that the password we want them to enter will always be "nadehousefortehlulz" <-- PS this is how you change the password
else if (password == "nadehousefortehlulz")
this.Visible = false;
Form2 NEXTWINDOW = new Form2();
and if it is valid we want the login screen to close and move to our next form, in this case Form2
Hang on.. What if they typed the wrong password?
This is our last check, if all else fails the program will read this code, and it is saying to show a messagebox saying what ever we put there
MessageBox.Show("Ha you are a noob", "Invalid Password")
Wait, I want the password system you used in your trainer, where it closes on the 5th attempt!
This is simple
Above our code we will add
int fail = 1;
and inside our code when ever they do something wrong add
This will add a count to fail
Thus fail = 2 now.
How to make the program close on the 5th attempt?
Add a timer,
if (fail ==5)
Now this is the fun part, notice how mine changes colour every time it goes up and the text changes on the label?
We could add things to the timer such as more if's
Hold up you may say, why HTML colours? I used to play a game where you could use HTML codes in your guild announcments so I know a few off by heart soo yeah >.>
if (fail ==4)
label1.ForeColor = System.Drawing.Color.Translator.FromHtml("#FF0000");
Mess around with this people!
Show me your screenshots I wanna see what you younge minds can do!
Now for le picture