onclick event of the login button ()
int i =0;
int password;
string username;
password = int.Parse(mtbPassword.Text);
username = Convert.ToString(cbxUsername.Text);
count ++;
if count > 3 exit sub;
for each string item in usernames {
if item.equals(username) {
if passwords[i].equals(password) {
'login or whatever
count = 0;
} else {
'incorrect password you have "count" goes left
exit sub;
}
}
i++;
}
username = cbxUsername.text is fine.username = Convert.ToString(cbxUsername.Text);
//global
string[][] userList = new[] { new[] { "Christopher Lightburn", "12345" }, new[] { "Jake McCalvey", "11111" }, new[] { "Paul Jobling", "22222" }, new[] { "John Deary", "33333" }, new[] { "Michael Humphreys", "44444" } };
int count = 0;
//private
string password = mtbPassword.Text;
string username = cbxUsername.Text;
bool valid = false;
foreach (string[] s in userList)
{
if (username != s[0] || password != s[1]) continue;
valid = true;
break;
}
if (valid)
{
//successfully logged in
}
else if (count < 3)
{
count++;
}
else
{
//exit application
}