0% found this document useful (0 votes)
43 views1 page

C# Windows Forms Calculator Code

This document contains C# code for a Windows Forms application. It defines a Form class with handlers for button click events. When buttons are clicked, text is added to a text box or a running total is displayed in a label. A boolean tracks whether text entry or calculation mode is active.

Uploaded by

Nguyễn Hậu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views1 page

C# Windows Forms Calculator Code

This document contains C# code for a Windows Forms application. It defines a Form class with handlers for button click events. When buttons are clicked, text is added to a text box or a running total is displayed in a label. A boolean tracks whether text entry or calculation mode is active.

Uploaded by

Nguyễn Hậu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

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 c
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool TestNoi = true;
int value = 0;

private void button_Click(object sender, EventArgs e)


{
if(TestNoi==true)
{
Button a = (Button)sender;
txtKetQua.Text = txtKetQua.Text + a.Text;
TestNoi = false;
}

private void noi_click(object sender, EventArgs e)


{
TestNoi = true;
}

private void Cong_Click(object sender, EventArgs e)


{
Button c = (Button)sender;
value = int.Parse(txtKetQua.Text);
lab.Text = txtKetQua.Text + c.Text;
txtKetQua.Text = "";
TestNoi = true;
}

private void Form1_Load(object sender, EventArgs e)


{

private void button6_Click(object sender, EventArgs e)


{
txtKetQua.Text = (value + int.Parse(txtKetQua.Text)).ToString();
}
}
}

You might also like