Latest topics
» Tự học lập trình IOS trong vòng 24hby kenanh 27/1/2014, 22:28
» xin tài liệu một số môn học
by nguyentvvan 21/8/2013, 21:34
» [Thảo luận] Bài toán đong nước
by giathinh9x 9/1/2013, 22:39
» Học Marketing Online, Học Chuyên viên Internet Marketing Online tại iNET
by NIIT-iNET 19/6/2012, 14:23
» Học PHP nâng cao, Học lập trình web với PHP nâng cao tại học viện iNET
by NIIT-iNET 19/6/2012, 14:22
» Học PHP, học lập trình web với PHP tại iNET vào ngày 19/07/2012
by NIIT-iNET 19/6/2012, 14:20
» PHIÊN BẢN MỚI CHO THIÊN ĐƯỜNG CÁ Ô LA LA !!!
by todaytv 13/3/2012, 15:35
» [hot] game khu vườn địa đàng phiên bản mobile của KVTM
by trantinh1713 3/1/2012, 15:20
» Đề tham khảo (update phút 90)
by ndc_2209 29/12/2011, 10:26
» Học bổng Lời Dịch tuần này.
by tienganh123 1/11/2011, 13:13
» [Thảo luận] Quản lý phân công giảng dạy PTTH
by huyquang0510 5/10/2011, 09:52
» Học tiếng Nhật - Top Globis
by tuquynh 21/9/2011, 10:35
» Học tiếng Nhật - Top Globis
by tuquynh 8/8/2011, 11:19
» Order Imitrex Online
by Khách viếng thăm 4/8/2011, 18:46
» Speeds Caffeine Metabolism Up
by Khách viếng thăm 4/8/2011, 18:12
» Skin For Good Caffeine
by Khách viếng thăm 3/8/2011, 14:54
» Cheap Pvc Figures
by Khách viếng thăm 1/8/2011, 19:32
» Action Rapid Onset Zolpidem Of
by Khách viếng thăm 31/7/2011, 01:13
» TUYỂN NHÂN VIÊN KINH DOANH ( làm việc tại văn phòng )
by canhkientp 5/7/2011, 14:59
» Demo + Vài điểm thảo luận về LINQ - Nhóm 7
by ChuongTienPhat 3/7/2011, 12:19
Calculator
+2
gecko
TranNgocSang
6 posters
Trang 1 trong tổng số 1 trang
gecko-
Tổng số bài gửi : 17
Age : 34
Registration date : 08/03/2010
Re: Calculator
TranNgocSang đã viết:Download Tại đây
Thanks các pác đã chia sẻ code.
Nhưng nếu các pác post code và chú giải từng hàm để giảng cho mọi người đính kèm source code như thế thì chắc sẽ tốt hơn nữa
Mong các pác tiếp tục phát huy
Re: Calculator
code cua pac gecko còn trục trặc chỗ buttondaucham_Click ai có xài code đó thì sữa lại
Re: Calculator
- Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Nhóm3_Calculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void txtCalculator_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar >= '0') && (e.KeyChar <= '9'))
e.Handled = false;
else
e.Handled = true;
}
private void Form1_Load(object sender, EventArgs e)
{
txtCalculator.Text = "0";
}
private void txtCalculator_TextChanged(object sender, EventArgs e)
{
}
void ham(Button t)
{
if (txtCalculator.Text.Length <= 20)
txtCalculator.AppendText(t.Text);
}
void kiemtra()
{
if (txtCalculator.Text == "0") txtCalculator.Text = "";
}
private void bt0_Click(object sender, EventArgs e)
{
kiemtra();
ham(bt0);
}
private void bt1_Click(object sender, EventArgs e)
{
kiemtra();
ham(bt1);
}
private void bt2_Click(object sender, EventArgs e)
{
kiemtra();
ham(bt2);
}
private void bt3_Click(object sender, EventArgs e)
{
kiemtra();
ham(bt3);
}
private void bt4_Click(object sender, EventArgs e)
{
kiemtra();
ham(bt4);
}
private void bt5_Click(object sender, EventArgs e)
{
kiemtra();
ham(bt5);
}
private void bt6_Click(object sender, EventArgs e)
{
kiemtra();
ham(bt6);
}
private void bt7_Click(object sender, EventArgs e)
{
kiemtra();
ham(bt7);
}
private void bt8_Click(object sender, EventArgs e)
{
kiemtra();
ham(bt8);
}
private void bt9_Click(object sender, EventArgs e)
{
kiemtra();
ham(bt9);
}
private void frmCalculator_KeyPress(object sender, KeyPressEventArgs e)
{
//Xử lý khi nhấn số
if (e.KeyChar == '0')
txtCalculator.AppendText("0");
else if (e.KeyChar == '1')
txtCalculator.AppendText("1");
else if (e.KeyChar == '2')
txtCalculator.AppendText("2");
else if (e.KeyChar == '3')
txtCalculator.AppendText("3");
else if (e.KeyChar == '4')
txtCalculator.AppendText("4");
else if (e.KeyChar == '5')
txtCalculator.AppendText("5");
else if (e.KeyChar == '6')
txtCalculator.AppendText("6");
else if (e.KeyChar == '7')
txtCalculator.AppendText("7");
else if (e.KeyChar == '8')
txtCalculator.AppendText("8");
else if (e.KeyChar == '9')
txtCalculator.AppendText("9");
}
private void btCongtru_Click(object sender, EventArgs e)
{
double i = double.Parse(txtCalculator.Text);
double j = i * (-1);
txtCalculator.Text = j.ToString();
}
int i = 0;
private void btCham_Click(object sender, EventArgs e)
{
i++;
if (i == 1)
{
txtCalculator.AppendText(".");
}
}
double SoThuNhat;
char ch;
private void btCong_Click(object sender, EventArgs e)
{
SoThuNhat = double.Parse(txtCalculator.Text);
ch = '+';
txtCalculator.Text = "";
i = 0;
}
private void btTru_Click(object sender, EventArgs e)
{
SoThuNhat = double.Parse(txtCalculator.Text);
ch = '-';
txtCalculator.Text = "";
i = 0;
}
private void btNhan_Click(object sender, EventArgs e)
{
SoThuNhat = double.Parse(txtCalculator.Text);
ch = '*';
txtCalculator.Text = "";
i = 0;
}
private void btChia_Click(object sender, EventArgs e)
{
SoThuNhat = double.Parse(txtCalculator.Text);
ch = '/';
txtCalculator.Text = "";
i = 0;
}
private void btBang_Click(object sender, EventArgs e)
{
double SoThuHai = double.Parse(txtCalculator.Text);
double KQ;
//Phép cộng
if (ch == '+')
{
KQ = SoThuNhat + SoThuHai;
txtCalculator.Text = KQ.ToString();
}
//Phép -
if (ch == '-')
{
KQ = SoThuNhat - SoThuHai;
txtCalculator.Text = KQ.ToString();
}
//Phép *
if (ch == '*')
{
KQ = SoThuNhat * SoThuHai;
txtCalculator.Text = KQ.ToString();
}
//Phép /
if (ch == '/')
{
KQ = SoThuNhat / SoThuHai;
txtCalculator.Text = KQ.ToString();
}
}
private void btSqrt_Click(object sender, EventArgs e)
{
double a = double.Parse(txtCalculator.Text);
if (a < 0)
txtCalculator.Text = "Error!Số âm không có căn bậc 2";
else
{
a = Math.Sqrt(a);
txtCalculator.Text = a.ToString();
}
}
private void btBinhphuong_Click(object sender, EventArgs e)
{
double a = double.Parse(txtCalculator.Text);
a = a * a;
txtCalculator.Text = a.ToString();
}
private void btNghichdao_Click(object sender, EventArgs e)
{
double bien = double.Parse(txtCalculator.Text);
double KQ;
KQ = 1 / bien;
txtCalculator.Text = KQ.ToString();
}
private void btC_Click(object sender, EventArgs e)
{
txtCalculator.Text = "0";
}
private void btBackspace_Click(object sender, EventArgs e)
{
if (txtCalculator.Text != "")
{
txtCalculator.Text = txtCalculator.Text.Remove(txtCalculator.Text.Length - 1);
if (txtCalculator.Text == "") txtCalculator.Text = "0";
}
}
private void frmCalculator_Load(object sender, EventArgs e)
{
txtCalculator.Text = "0";
}
private void btCE_Click(object sender, EventArgs e)
{
txtCalculator.Text = "0";
}
private double nho;
private void btMCong_Click(object sender, EventArgs e)
{
nho = double.Parse(txtCalculator.Text);
}
private void btMR_Click(object sender, EventArgs e)
{
txtCalculator.Text = nho.ToString();
}
private void btMC_Click(object sender, EventArgs e)
{
nho = 0;
}
private void đóngToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Edit bài của lhminhchau qua
PhamDuyTan- Admin
-
Tổng số bài gửi : 383
Age : 35
Registration date : 13/03/2008
Re: Calculator
chết, em copy tài liệu của người ta...nam mô a di đà phật...
gecko-
Tổng số bài gửi : 17
Age : 34
Registration date : 08/03/2010
Trang 1 trong tổng số 1 trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết
|
|