Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- c# datagridview 데이터 넣기
- transfer
- Replication
- map이 undefined가 뜰 때
- DataGridView 직접 입력
- html #select #option #multiple
- datagridview 직접입력
- setInterval 중지
- invalid data
- allow_anonymouse
- pm2 상태 확인
- setInterval clear
- setInterval 외부 정지
- mosquitto.conf
- DatePicker
- AntDesign
- 맥 어드레스
- pm2 설치
- 데이터테이블 데이터 넣기
- pm2 시작
- pm2 확인
- 1883
- 서버동기화
- listener 1883
- timepicker
- 공인IP
- mySQL_Replication
- pm2
- mosquitto
- setInterval 정지
Archives
- Today
- Total
개발 노트
c# 계산기 코드 본문
https://github.com/zakigaebal/c_calculator
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 WindowsFormsApp5
{
public partial class Form1 : Form
{
Boolean bFlag = true;
Boolean bclear = false;
int icompute = 0;
int iop = -1;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (bclear == true)
{
textBox1.Text = "1";
bclear = false;
}
else
{
textBox1.Text += "1";
}
}
private void button2_Click(object sender, EventArgs e)
{
if (bclear == true)
{
textBox1.Text = "2";
bclear = false;
}
else
{
textBox1.Text += "2";
}
}
private void buttonmi_Click(object sender, EventArgs e)
{
switch (iop)
{
case -1:
icompute = Convert.ToInt32(textBox1.Text);
break;
case 0:
icompute += Convert.ToInt32(textBox1.Text);
break;
case 1:
icompute -= Convert.ToInt32(textBox1.Text);
break;
case 2:
icompute *= Convert.ToInt32(textBox1.Text);
break;
case 3:
icompute /= Convert.ToInt32(textBox1.Text);
break;
}
iop = 1;
bclear = true;
}
private void buttonplus_Click(object sender, EventArgs e)
{
switch (iop)
{
case -1:
icompute = Convert.ToInt32(textBox1.Text);
break;
case 0:
icompute += Convert.ToInt32(textBox1.Text);
break;
case 1:
icompute -= Convert.ToInt32(textBox1.Text);
break;
case 2:
icompute *= Convert.ToInt32(textBox1.Text);
break;
case 3:
icompute /= Convert.ToInt32(textBox1.Text);
break;
}
iop = 0;
bclear = true;
}
private void buttoneq_Click(object sender, EventArgs e)
{
switch (iop)
{
case -1:
icompute = Convert.ToInt32(textBox1.Text);
break;
case 0:
icompute += Convert.ToInt32(textBox1.Text);
break;
case 1:
icompute -= Convert.ToInt32(textBox1.Text);
break;
case 2:
icompute *= Convert.ToInt32(textBox1.Text);
break;
case 3:
icompute /= Convert.ToInt32(textBox1.Text);
break;
}
iop = -1;
textBox1.Text = Convert.ToString(icompute);
icompute = 0;
bclear = true;
}
private void button3_Click(object sender, EventArgs e)
{
if (bclear == true)
{
textBox1.Text = "3";
bclear = false;
}
else
{
textBox1.Text += "3";
}
}
private void button4_Click(object sender, EventArgs e)
{
if (bclear == true)
{
textBox1.Text = "4";
bclear = false;
}
else
{
textBox1.Text += "4";
}
}
private void button5_Click(object sender, EventArgs e)
{
if (bclear == true)
{
textBox1.Text = "5";
bclear = false;
}
else
{
textBox1.Text += "5";
}
}
private void button6_Click(object sender, EventArgs e)
{
if (bclear == true)
{
textBox1.Text = "6";
bclear = false;
}
else
{
textBox1.Text += "6";
}
}
private void button7_Click(object sender, EventArgs e)
{
if (bclear == true)
{
textBox1.Text = "7";
bclear = false;
}
else
{
textBox1.Text += "7";
}
}
private void button8_Click(object sender, EventArgs e)
{
if (bclear == true)
{
textBox1.Text = "8";
bclear = false;
}
else
{
textBox1.Text += "8";
}
}
private void button9_Click(object sender, EventArgs e)
{
if (bclear == true)
{
textBox1.Text = "9";
bclear = false;
}
else
{
textBox1.Text += "9";
}
}
private void button0_Click(object sender, EventArgs e)
{
if (bclear == true)
{
}
else
{
textBox1.Text += "0";
}
}
private void button15_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length > 0)
{
textBox1.Text = textBox1.Text.Substring(0, textBox1.Text.Length - 1);
}
}
private void button13_Click(object sender, EventArgs e)
{
icompute = 0;
iop = -1;
bclear = true;
textBox1.Text = "";
}
private void buttonMultify_Click(object sender, EventArgs e)
{
switch (iop)
{
case -1:
icompute = Convert.ToInt32(textBox1.Text);
break;
case 0:
icompute += Convert.ToInt32(textBox1.Text);
break;
case 1:
icompute -= Convert.ToInt32(textBox1.Text);
break;
case 2:
icompute *= Convert.ToInt32(textBox1.Text);
break;
case 3:
icompute /= Convert.ToInt32(textBox1.Text);
break;
}
iop = 2;
bclear = true;
}
private void buttonDivide_Click(object sender, EventArgs e)
{
switch (iop)
{
case -1:
icompute = Convert.ToInt32(textBox1.Text);
break;
case 0:
icompute += Convert.ToInt32(textBox1.Text);
break;
case 1:
icompute -= Convert.ToInt32(textBox1.Text);
break;
case 2:
icompute *= Convert.ToInt32(textBox1.Text);
break;
case 3:
icompute /= Convert.ToInt32(textBox1.Text);
break;
}
iop = 3;
bclear = true;
}
}
}
결과
- 정말 마이크로소프트 계산기는 잘만든것같다는게 느껴짐
'프로그래밍 > C#' 카테고리의 다른 글
투두리스트 만들어보기 참고자료 (0) | 2022.01.11 |
---|---|
c# 계산기 참고자료 (0) | 2022.01.11 |
c# 계산기 레이아웃잡기 (0) | 2022.01.11 |
간단한 사칙연산 프로그램 (0) | 2022.01.11 |
c# 조건문,switchcase (0) | 2022.01.11 |