Dont work, it´s something whit the loops?

Joined
Jun 30, 2021
Messages
1
Reaction score
0
private void buttonCheck_Click(object sender, EventArgs e)
{
int[] ModPassword = { 1, 1, 1, 1, 1};
int DerIndex;

Random rnd = new Random();
ModiPassword.ResetText();
string PasswordUser = BoxPassword.Text;



if (PasswordUser.Length >= 10)
{
ResultCheck1.ResetText();
ResultCheck1.ForeColor = System.Drawing.Color.Green;
ResultCheck1.Text += "Enough Charakters;";
}
else
{
ResultCheck1.ResetText();
ResultCheck1.ForeColor = System.Drawing.Color.Red;
ResultCheck1.Text += " Not enough Charakters;";
ModPassword[0]++;
}

if (PasswordUser.Any(char.IsUpper))
{
ResultCheck2.ResetText();
ResultCheck2.ForeColor = System.Drawing.Color.Green;
ResultCheck2.Text += "Capital Letter(s);";
}
else
{
ResultCheck2.ResetText();
ResultCheck2.ForeColor = System.Drawing.Color.Red;
ResultCheck2.Text += "Has no Capital Letter(s);";
ModPassword[1]++;
}

if (PasswordUser.Any(char.IsLower))
{
ResultCheck3.ResetText();
ResultCheck3.ForeColor = System.Drawing.Color.Green;
ResultCheck3.Text += "Low Letter(s)";
}
else
{
ResultCheck3.ResetText();
ResultCheck3.ForeColor = System.Drawing.Color.Red;
ResultCheck3.Text += "Has no low Letter(s)";
ModPassword[2]++;
}

if (PasswordUser.Any(char.IsDigit))
{
ResultCheck4.ResetText();
ResultCheck4.ForeColor = System.Drawing.Color.Green;
ResultCheck4.Text += "Has a Number(s)";
}
else
{
ResultCheck4.ResetText();
ResultCheck4.ForeColor = System.Drawing.Color.Red;
ResultCheck4.Text += "Has no Number(s)";
ModPassword[3]++;
}

if (PasswordUser.Contains("!"))
{
ResultCheck5.ResetText();
ResultCheck5.ForeColor = System.Drawing.Color.Green;
ResultCheck5.Text += "Has a !";
}
else
{
ResultCheck5.ResetText();
ResultCheck5.ForeColor = System.Drawing.Color.Red;
ResultCheck5.Text += "Has no !";
ModPassword[4]++;
}

string newPsw = PasswordUser;
string newPsw2 = "";
string newPsw3 = "";
string newPsw4 = "";
string newPsw5 = "";
string newPsw6 = "";
string newPsw7 = "";
string newPsw8 = "";
string newPsw9 = "";
string newPsw10 = "";
string newPassword = "";
string Number = "";
int count = 0;
for (int i = 0; i < ModPassword.Length; i++)
{
if (ModPassword == 2)
{

DerIndex = i;
switch (i)
{
case 0:
Guid B = Guid.NewGuid();
string GuidStrings = Convert.ToBase64String(B.ToByteArray());
GuidStrings = GuidStrings.Replace("=", "");
GuidStrings = GuidStrings.Replace("+", "");
newPassword = PasswordUser + GuidStrings;

break;
case 1:

int numUps1 = rnd.Next(1, 11);
int numUps2 = rnd.Next(1, numUps1);

for (int a = 1; a >= numUps2; a++)
{

int whereUps = rnd.Next(0, PasswordUser.Length);
int whatUps = rnd.Next(1, 27);

switch (whatUps)
{
case 1:
Number = "A";
break;
case 2:
Number = "B";
break;
case 3:
Number = "C";
break;
case 4:
Number = "D";
break;
case 5:
Number = "E";
break;
case 6:
Number = "F";
break;
case 7:
Number = "G";
break;
case 8:
Number = "H";
break;
case 9:
Number = "I";
break;
case 10:
Number = "J";
break;
case 11:
Number = "K";
break;
case 12:
Number = "L";
break;
case 13:
Number = "M";
break;
case 14:
Number = "N";
break;
case 15:
Number = "O";
break;
case 16:
Number = "P";
break;
case 17:
Number = "Q";
break;
case 18:
Number = "R";
break;
case 19:
Number = "S";
break;
case 20:
Number = "T";
break;
case 21:
Number = "U";
break;
case 22:
Number = "V";
break;
case 23:
Number = "W";
break;
case 24:
Number = "X";
break;
case 25:
Number = "Y";
break;
case 26:
Number = "Z";
break;
}

switch (a)
{
case 1:
newPsw = PasswordUser.Insert(whereUps, Number);
count++;
break;
case 2:
newPsw2 = newPsw.Insert(whereUps, Number);
count++;
break;
case 3:
newPsw3 = newPsw2.Insert(whereUps, Number);
count++;
break;
case 4:
newPsw4 = newPsw3.Insert(whereUps, Number);
count++;
break;
case 5:
newPsw5 = newPsw4.Insert(whereUps, Number);
count++;
break;
case 6:
newPsw6 = newPsw5.Insert(whereUps, Number);
count++;
break;
case 7:
newPsw7 = newPsw6.Insert(whereUps, Number);
count++;
break;
case 8:
newPsw8 = newPsw7.Insert(whereUps, Number);
count++;
break;
case 9:
newPsw9 = newPsw8.Insert(whereUps, Number);
count++;
break;
case 10:
newPsw10 = newPsw9.Insert(whereUps, Number);
count++;
break;

}


}
switch (count)
{
case 1:
newPassword = newPsw;
break;
case 2:
newPassword = newPsw2;
break;
case 3:
newPassword = newPsw3;
break;
case 4:
newPassword = newPsw4;
break;
case 5:
newPassword = newPsw5;
break;
case 6:
newPassword = newPsw6;
break;
case 7:
newPassword = newPsw7;
break;
case 8:
newPassword = newPsw8;
break;
case 9:
newPassword = newPsw9;
break;
case 10:
newPassword = newPsw10;
break;
}
break;
case 2:
break;
case 3:
break;
case 4:
break;
}

break;
}
}
ModiPassword.Text = newPassword;
Array.Clear(ModPassword, 0, 5);


}
}
I am getting no error but the switch statment whit (i) the case 1 doesnt work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top