1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
namespace _103303058_0420_01
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
radioButton1.Checked = true;
radioButton3.Checked = true;

}

private void button1_Click(object sender, EventArgs e)
{



double No1 = 0;
double No2 = 0;
double No3 = 0;
double Sum = 0;

DialogResult MBoxResult = MessageBox.Show("確定要計算嘛?","MsgBox",MessageBoxButtons.YesNoCancel);


if (MBoxResult == DialogResult.Yes)
{
No1 = Convert.ToDouble(maskedTextBox1.Text);
No2 = Convert.ToDouble(maskedTextBox2.Text);
No3 = Convert.ToDouble(maskedTextBox3.Text);

if (radioButton1.Checked)
{
Sum = No1 + No2;
}
else
{
Sum = No1 - No2;
}

if (radioButton3.Checked)
{
Sum = Sum + No3;
}
else
{
Sum = Sum - No3;
}

textBox1.Text = Sum.ToString("F2");

}

}
}
}