반응형

//C# 윈도우 폼 계산기 만들기


        private void button1_Click(object sender, EventArgs e)
        {
            int a = int.Parse(tbxData1.Text);
            int b = int.Parse(tbxData2.Text);

            rbx1.Text = (a + b).ToString()   

   }

 

// 숫자 입력한 뒤 버튼을 누르면 더한 결과가 나온다.

 

 

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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 WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        int question_a = 0, question_b = 0;
        public Form1()
        {
            InitializeComponent();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
 
            //int a = int.Parse(tbxData1.Text);
            //int b = int.Parse(tbxData2.Text);
 
            //rbx1.Text = (a + b).ToString();
 
            int a = question_a;
            int b = question_b;
            rbx1.Text =(a+b).ToString();
 
        }
 
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
           
           
        }
 
        private void textBox1_TextChanged_1(object sender, EventArgs e)
        {
 
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            question.Text = "+";
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
 
        }
 
        private void rbx1_TextChanged(object sender, EventArgs e)
        {
 
        }
 
        private void num1_Click(object sender, EventArgs e)
        {
            question.Text += 1.ToString();
           
        }
 
        private void minus_Click(object sender, EventArgs e)
        {
            question.Text = "-";
        }
 
        private void clear_Click(object sender, EventArgs e)
        {
            question.Clear();
        }
 
        private void mul_Click(object sender, EventArgs e)
        {
            question.Text = "*";
        }
 
        private void div_Click(object sender, EventArgs e)
        {
            question.Text = "/";
        }
 
        private void del_Click(object sender, EventArgs e)
        {
 
        }
 
        private void num3_Click(object sender, EventArgs e)
        {
            question.Text += 3.ToString();
        }
 
        private void num4_Click(object sender, EventArgs e)
        {
            question.Text += 4.ToString();
        }
 
        private void num5_Click(object sender, EventArgs e)
        {
            question.Text += 5.ToString();
        }
 
        private void num6_Click(object sender, EventArgs e)
        {
            question.Text += 6.ToString();
        }
 
        private void num7_Click(object sender, EventArgs e)
        {
            question.Text += 7.ToString();
        }
 
        private void num8_Click(object sender, EventArgs e)
        {
            question.Text += 8.ToString();
        }
 
        private void num9_Click(object sender, EventArgs e)
        {
            question.Text += 9.ToString();
        }
 
        private void num0_Click(object sender, EventArgs e)
        {
            question.Text += 0.ToString();
        }
 
        private void num2_Click(object sender, EventArgs e)
        {
            question.Text += 2.ToString();
 
        }
    }
}
 
cs

 

 

 

반응형

'Study > C#' 카테고리의 다른 글

C# - 닷지 게임 만들기  (0) 2018.08.30
C# - 비행기 자유롭게 움직이기  (0) 2018.08.30
C# - 공튀기기 (particles.js)  (0) 2018.08.30
C# - 이벤트  (0) 2018.08.30
C# - 계산기 만들기2  (0) 2018.08.30

+ Recent posts