I have a part of my program that does several checks when the button is clicked and one of these checks is: it takes the value entered in textboxRankTecnica
and has to buy with the array ranksAceitaveis
. If it enters a value that is not in ranksAceitaveis
, it must display MessageBox
. If it is the same, it continues with the code, but the big problem is that even typing an acceptable value, it throws textbox
. Codes that I have already tried (none of them did what they wanted, because even typing a correct value, it returns the message):
string[] ranksAceitaveis = new string[] { "E", "E+", "D", "D+", "C", "C+", "B", "B+", "A", "A+", "S", "S+", "S++" };
else if (textBoxRankTecnica.Text.Length > 0)
{
for (int i = 0; i <= (ranksAceitaveis.Length - 1); i++)
{
if (!textBoxRankTecnica.Text.Contains(ranksAceitaveis[i]))
{
passouCriacao = false;
MessageBox.Show("O Rank digitado é inválido [...]".", "Rank inválido", MessageBoxButtons.OK, MessageBoxIcon.Information);
break;
}
}
}
/*outro codigo:*/ string[] ranksAceitaveis = new string[] { "E", "E+", "D", "D+", "C", "C+" , "B", "B+", "A", "A+", "S", "S+", "S++"};
else if (textBoxRankTecnica.Text != ranksAceitaveis.ToString().ToLowerInvariant())
{
passouCriacao = false;
MessageBox.Show("O Rank inserido é inválido, digite um [...]".", "Rank inválido", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
/*outro codigo:*/ else if (textBoxRankTecnica.Text != "E".ToLowerInvariant() || textBoxRankTecnica.Text != "E+".ToLowerInvariant()) //E o resto das verificações
/*outro codigo:*/ else if (textBoxRankTecnica.Text.Length > 0)
{
for (int i = 0; i <= (ranksAceitaveis.Length - 1); i++)
{
if (textBoxRankTecnica.Text != ranksAceitaveis[i].ToString().ToLowerInvariant())
{
passouCriacao = false;
MessageBox.Show("Text [...]".", "Rank inválido", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}