黑马程序员-- .Net学习日记——WinForm

 

---------------------- Windows Phone 7手机开发Net培训、期待与您交流! ----------------------

 

修改密码

           string password = textBox1.Text;


            string password1 = textBox2.Text;


            string password2 = textBox3.Text;


            //判断旧密码的输入


            if (password != "888888")


            {


                MessageBox.Show("旧密码输入有误");


                return;


            }


            if (password1 != password2)


            {


                MessageBox.Show("新密码输入的不一致");


                return;


            }


            if (password == password1 || password == password2)


            {


                MessageBox.Show("旧密码不能和新密码重复");


                return;


            }
      
                MessageBox.Show("修改成功");

输出最高成绩

            string[] lines = textBox1.Lines;


            string maxname = "";


            int maxscore = -1;


            foreach (string line in lines)


            {


                string[] strs = line.Split('=');


                string name = strs[0];

                string strscore = strs[1];


                int score = Convert.ToInt32(strscore);


                if (score > maxscore)


                {


                    maxname = name;


                    maxscore = score;


                }

                MessageBox.Show(string.Format("{0}是第一名成绩{1}",maxname,maxscore));

登陆界面

            string username = textBox1.Text.Trim();


            string password = textBox2.Text.Trim();


           // 不区分大小写,用.Equals 中的方法 忽略大小写


            if (username.Equals( "admin", StringComparison.OrdinalIgnoreCase) && password =="888888")


            {


                MessageBox.Show("欢迎登录");


            }


                 或者        if (username == "admin" && password == "888888")


                                    {


                                         MessageBox.Show("欢迎登录");


                                    }


            else


            {

                if (i >= 3)


                {


                    MessageBox.Show("登录的次数过多,退出程序");


                    Application.Exit();


                }


                MessageBox.Show("密码或用户名错误,请重新登录");

计算运算器

            string str1 = textBox1.Text;


            string str2 = textBox2.Text;


            int i1,i2;


            if (int.TryParse(str1, out i1) == false)


            {


                MessageBox.Show("第一个输入错误");


                return;


            }


            if (int.TryParse(str2, out i2) == false)


            {


               MessageBox.Show("第二个输入错误");


               return;


            }


            int i3 = i2 + i1;


            textBox3.Text = Convert.ToString(i3);

四则运算器

string str1 = textBox1.Text;

            string str2 = textBox2.Text;

            int i1 = Convert.ToInt32(str1);

            int i2 = Convert.ToInt32(str2);

            int i3;

            switch (comboBox1.SelectedIndex)

            {

                case 0:

                    i3 = i1 + i2;

                    break;

                case 1:

                    i3 = i1 - i2;

break;

case 2:

                    i3 = i1 * i2;

                    break;

                case 3:

                    if (i2 == 0)

                    {

                        MessageBox.Show("除数不能为0");

                    }

                    i3 = i1 / i2;

                    break;

                default:

throw new Exception("未知的运算");

            }

textBox3.Text = Convert.ToString(i3);

----------------------Windows Phone 7手机开发Net培训、期待与您交流! ----------------------

详细请查看:http://net.itheima.com/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值