I'd like to run my switch and if/else statement again after the buttons are clicked three times in total.
The current pressed code is for three buttons with each 1 value. If those (current pressed code) are equal to the global string that contains a 3 number value, the picture box color will change to forest green. This is my code:
switch ((sender as Button).Text)
{
case "1":
serialMonitor.PrintLine("1");
currentPressedCode = currentPressedCode + "1";
break;
case "2":
serialMonitor.PrintLine("2");
currentPressedCode = currentPressedCodeR + "2";
break;
case "3":
serialMonitor.PrintLine("3");
currentPressedCode = currentPressedCode + "3";
break;
default:
break;
} if (buttonsPressed == 3)
{
if (currentPressedCode == vaultCode)
{
//vault open
serialMonitor.PrintLine("vault");
pcbGreen.BackColor = Color.ForestGreen;
}
}
else
{
// wrong code
serialMonitor.PrintLine("wrong");
MessageBox.Show("Wrong password"); // wrong password messagebox
pcbRed.BackColor = Color.DarkRed;
}
Aucun commentaire:
Enregistrer un commentaire