Chinaunix首页 | 论坛 | 博客
  • 博客访问: 113026
  • 博文数量: 32
  • 博客积分: 1222
  • 博客等级: 中尉
  • 技术积分: 350
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-08 16:36
个人简介

天高任鸟飞,海阔凭鱼跃

文章分类

全部博文(32)

文章存档

2011年(5)

2010年(27)

我的朋友
最近访客

分类:

2010-06-19 19:46:34

基于WEB服务的在线计算器

-----------------------------------

方法一:

--------------------------------

try

        {

            double a1 = Convert.ToDouble(TextBox1.Text);

            double a2 = Convert.ToDouble(TextBox2.Text);

            if (DropDownList1.SelectedValue == "+")

            {

                Label1.Text = Convert.ToString(a1 + a2);

 

            }

            else if (DropDownList1.SelectedValue == "-")

            {

                Label1.Text = Convert.ToString(a1 - a2);

            }

            else if (DropDownList1.SelectedValue == "*")

            {

                Label1.Text = Convert.ToString(a1 * a2);

            }

            else if (DropDownList1.SelectedValue == "/")

            {

                if (a2 == 0)

                {

                    Label1.Text = "被除数不能为零!";

                }

                else

                {

                    Label1.Text = Convert.ToString(a1 / a2);

                }

 

            }

        }

        catch

        {

            Label1.Text = "请在文本框内输入数字!";

        }

方法二:

------------------------

try

        {

 

 

            double a1 = Convert.ToDouble(TextBox1.Text);

            double a2 = Convert.ToDouble(TextBox2.Text);

            switch (DropDownList1.SelectedValue)

            {

                case "+":

                    Label1.Text = Convert.ToString(a1 + a2);

                    break;

                case "-":

                    Label1.Text = Convert.ToString(a1 - a2);

                    break;

                case "*":

                    Label1.Text = Convert.ToString(a1 * a2);

                    break;

                case "/":

                    Label1.Text = Convert.ToString(a1 / a2);

                    break;

 

            }

        }

        catch

        {

            Label1.Text = "请您在文本框内输入数字!";

        }

方法三:

-----------------------

        try

           {

 

 

            double a1 = Convert.ToDouble(TextBox1.Text);

            double a2 = Convert.ToDouble(TextBox2.Text);

          

            switch (DropDownList1.SelectedValue)

            {

               case "+":

                 

                  TextBox3.Text = Convert.ToString(a1+a2);

                  

                    break;

                case "-":

                  TextBox3.Text = Convert.ToString(a1 - a2);

                   break;

               case "*":

                    TextBox3.Text = Convert.ToString(a1 * a2);

                    break;

                case "/":

                    TextBox3.Text = Convert.ToString(a1 / a2);

                    break;

 

           }

          }

        catch

        {

            Label1.Text = "请您在文本框内输入数字!";

        }

 

        ---------------------------------------------------------------

九九乘法口诀表

-------------------------

方法:

九九乘法口诀表(数字型)

------------------------

for (int i = 1; i <= 9; i++)

        {

            for (int j = 1; j <= i; j++)

            {

               

                Label1.Text=Label1.Text+i.ToString()+"x"+j.ToString()+"="+Convert.ToString(i*j)+" "+" ";

 

            } Label1.Text += "
";

        }

-----------------------------

 

阅读(847) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~