Hi, can anybody help me with creating some sort of while loop for my program, when a user enters an incorrect username and password 3 times I want the program to end. I have tried all sorts but I can't seem to get it right. Please take a look at my code below thanks.
// connect to database to check username and password
try {
// create an instance of class DbAccess
DbAccess ^ db = gcnew DbAccess();
// definition of variables
String ^userName = txtUserName->Text->Trim();// 'Trim' removes all white space
String ^password = txtPassword->Text->Trim();
// wrong username and password combination
if (!db->Verify(userName, password))
{
ViewMessage("Incorrect username and password combination!");
// clear text boxes
txtPassword->Text = "";
txtUserName->Text = "";
// focus to user text box
txtUserName->Focus();
return;
}
else { // correct user and password
// dialog result is ok so close form
this->DialogResult = System::Windows::Forms::DialogResult::OK; this->Close();
/* opens application - tells the complier what to do i.e execute window and tells it which path to take.
The WinExec() function takes two arguments, the first one specifies the location or
Command Line of the executable file or application, the second one specifies how the window
will be displayed when the application starts*/