0
私のプログラムでは、私は学生の学年を入力するtexboxesを持っています。しかし、私は010や020のような形式で数字を数字にしないように制限したいと思います。また、ユーザーが1桁を変更して別のテキストボックスに変更すると、自動的にこの数字(1)が1,0に変更されます。数字形式を受け入れないようにtexboxに制限する( "010")
私はこれを試しましたが、2番目の状態になるとエラーになります。
private void txt3Bimestre_Validated(object sender, EventArgs e)
{
if (txt3Bimestre.Text[0].ToString().Equals("1") ||
txt3Bimestre.Text[0].ToString().Equals("2") ||
txt3Bimestre.Text[0].ToString().Equals("3") ||
txt3Bimestre.Text[0].ToString().Equals("4") ||
txt3Bimestre.Text[0].ToString().Equals("5") ||
txt3Bimestre.Text[0].ToString().Equals("6") ||
txt3Bimestre.Text[0].ToString().Equals("7") ||
txt3Bimestre.Text[0].ToString().Equals("8") ||
txt3Bimestre.Text[0].ToString().Equals("9"))
{
if (txt3Bimestre.Text[1].ToString().Equals(",") || txt3Bimestre.Text.Substring(0, 2) == "10")
{
}
}
else
{
MessageBox.Show("Formato Inválido", "Alertaa", MessageBoxButtons.OK, MessageBoxIcon.Error);
txt3Bimestre.Clear();
txt3Bimestre.Focus();
}
}
あなたが行ったことを示す –
あなたはサイトも初めてで、[ask]と[tour] – Plutonix