%E6%9C%AA%E5%91%BD%E5%90%8D.png 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
        }



        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            String b1,b2;
            float c1;
              b1=textBox1.Text;
              float f1 = float.Parse(b1);
              b2 = textBox2.Text;
              float f2 = float.Parse(b2);
              Single.TryParse(b2, out f2);
              c1=f1+f2;
              label2.Text = c1.ToString();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            String b1, b2;
            float c1;
            b1 = textBox1.Text;
            float f1 = float.Parse(b1);
            b2 = textBox2.Text;
            float f2 = float.Parse(b2);
            Single.TryParse(b2, out f2);
            c1 = f1 * f2;
            label2.Text = c1.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            String b1, b2;
            float c1;
            b1 = textBox1.Text;
            float f1 = float.Parse(b1);
            b2 = textBox2.Text;
            float f2 = float.Parse(b2);
            Single.TryParse(b2, out f2);
            c1 = f1 - f2;
            label2.Text = c1.ToString();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            String b1, b2;
            float c1;
            b1 = textBox1.Text;
            float f1 = float.Parse(b1);
            b2 = textBox2.Text;
            float f2 = float.Parse(b2);
            Single.TryParse(b2, out f2);
            c1 = f1 / f2;
            label2.Text = c1.ToString();
            if (f2 == 0)
                label2.Text = "無法除以零";
        }
    }
}


arrow
arrow
    全站熱搜

    darkspirits 發表在 痞客邦 留言(0) 人氣()