'목록하단 광고 치환자(withSeok)
728x90

따라한 강의 : youtu.be/Xer0j5U24Q0

[C# 초보 강좌] 예제로 배우는 C# 05



계산기 파일

WF_Cal_2.exe
0.01MB

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
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 WF_Cal_1
{
     public partial class Form1 : Form
     {
        public Form1()
        {
            InitializeComponent();
        }
 
        public int vResult = 0;
        public bool isNewNum = true;
 
 
        private void bttnN1_Click(object sender, EventArgs e)
        { SetNum("1"); }
        private void bttnN2_Click(object sender, EventArgs e)
        { SetNum("2"); }
        private void bttn3_Click(object sender, EventArgs e)
        { SetNum("3"); }
        private void bttn4_Click(object sender, EventArgs e)
        { SetNum("4"); }
        private void bttn5_Click(object sender, EventArgs e)
        { SetNum("5"); }
        private void bttn6_Click(object sender, EventArgs e)
        { SetNum("6"); }
        private void bttn7_Click(object sender, EventArgs e)
        { SetNum("7"); }
        private void bttn8_Click(object sender, EventArgs e)
        { SetNum("8"); }
        private void bttn9_Click(object sender, EventArgs e)
        { SetNum("9"); }
        private void bttn0_Click(object sender, EventArgs e)
        { SetNum("0"); }
        public void SetNum(string num)
        {
            if (isNewNum)
            {
                lblNumscreen.Text = num;
                isNewNum = false;
            }
            else if (lblNumscreen.Text == "0")
            {
                lblNumscreen.Text = num;
            }
            else
            {
                lblNumscreen.Text = lblNumscreen.Text + num;
            }
        }
 
        private void bttnPlus_Click(object sender, EventArgs e)
        {
            int num = int.Parse(lblNumscreen.Text);
            vResult = vResult + num;
            lblNumscreen.Text = vResult.ToString();
            isNewNum = true;
        }
    }
}
 
cs
728x90

+ Recent posts