private void btnShow_Click(object sender, EventArgs e)
{
//2.任意从文本框接受6个数 将最大的数 显示出来
int A = 0;
int B = 0;
int C = 0;
int D = 0;
int E = 0;
int F = 0;
bool b1, b2, b3, b4, b5, b6;
b1 = int.TryParse(this.textBox1.Text, out A);
b2 = int.TryParse(this.textBox2.Text, out B);
b3 = int.TryParse(this.textBox3.Text, out C);
b4 = int.TryParse(this.textBox4.Text, out D);
b5 = int.TryParse(this.textBox5.Text, out E);
b6 = int.TryParse(this.textBox6.Text, out F);
if (b1 == false || b2 == false || b3 == false || b4 == false || b5 == false || b6 == false)
{
MessageBox.Show("每一个文本框里面必须输入的是数字");
}
else
{
int[] intArrayValue = new int[6];
intArrayValue[0] = int.Parse(this.textBox1.Text);
intArrayValue[1] = int.Parse(this.textBox2.Text);
intArrayValue[2] = int.Parse(this.textBox3.Text);
intArrayValue[3] = int.Parse(this.textBox4.Text);
intArrayValue[4] = int.Parse(this.textBox5.Text);
intArrayValue[5] = int.Parse(this.textBox6.Text);
int Max = intArrayValue[0];
for (int i = 0; i < intArrayValue.Length; i++)
{
if (Max < intArrayValue[i])
{
Max = intArrayValue[i];
}
}
MessageBox.Show("以上六个数中最大数字为" + Max.ToString());
}
}
private void btnShow_Click(object sender, EventArgs e)
{
//3.根据输入的字符串,判断是否是回文(例如:上海自来水来自海上)
if (this.txtGetValue.Text == "")
{
MessageBox.Show("文本框不能为空");
}
else
{
string strA = this.txtGetValue.Text;
char[] charA = strA.ToCharArray();
Array.Reverse(charA);
string strB = new string(charA);
if (strA == strB)
{
MessageBox.Show("该句话是回文");
}
else
{
MessageBox.Show("该句话不是回文,请重新输入");
this.txtGetValue.Text = "";
}
}
}
private void btnShow2_Click(object sender, EventArgs e)
{
if (this.txtGetValue.Text == "")
{
MessageBox.Show("文本框不能为空");
}
else
{
string strA = this.txtGetValue.Text;
string strB = "";
for (int i = 0; i < strA.Length; i++)
{
strB+= strA.Substring(strA.Length - 1 - i, 1);
}
if (strA == strB)
{
MessageBox.Show("该句话是回文");
}
else
{
MessageBox.Show("该句话不是回文,请重新输入");
this.txtGetValue.Text = "";
}
}
private void btnShow_Click(object sender, EventArgs e)
{
if (this.txtName.Text == "" || this.txtPwd1.Text == "" || this.txtPwd2.Text == "" || this.txtMoney.Text == "")
{
MessageBox.Show("所有内容不能为空");
}
else
{
string strName = this.txtName.Text;
if (strName.Length > 6)
{
MessageBox.Show("输入的用户名长度不能超过6位,请重新输入");
this.txtName.Text = "";
}
else
{
char[] charArrayName = strName.ToCharArray();
for (int i = 0; i < charArrayName.Length; i++)
{
if (char.IsNumber(charArrayName[i]) == false)
{
MessageBox.Show("你输入的用户名不合法,请重新输入");
this.txtName.Text = "";
return;
}
}
MessageBox.Show("恭喜您,您输入的用户名合法");
//this.labMessage.Text = string.Format("你的用户名合法,为{0}", strName)+" ";
string strPwd1 = this.txtPwd1.Text;
char[] charArrayPwd = strPwd1.ToCharArray();
for (int j = 0; j < charArrayPwd.Length; j++)
{
if (char.IsLetter(charArrayPwd[j]) == false)
{
MessageBox.Show("你输入的密码格式有误,只能为字母,请重新输入");
this.txtPwd1.Text = "";
return;
}
}
string strPwd2 = this.txtPwd2.Text;
if (strPwd1 == strPwd2)
{
string strMoney = this.txtMoney.Text;
this.labMessage.Text += string.Format("你的用户名为{0},密码为{1},金额为{2}", strName, strPwd1.ToUpper(),(int.Parse(strMoney)).ToString("#.00"));
}
else
{
MessageBox.Show("两次输入密码不一致,请重新输入");
this.txtPwd1.Text = "";
this.txtPwd2.Text = "";
}
}
}
}