帮忙~~~

leighxu 2006-10-25 11:12:54
请问哪位大虾有跟开始-程序-附件-计算器.做的跟这计算器差不多的代码有吗?请发至我邮箱..先谢大虾了..或者跟那里面的写字板差不多的也行..xli0501@163.com
...全文
112 9 打赏 收藏 举报
写回复
9 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
leighxu 2006-10-29
  • 打赏
  • 举报
回复
还没人??
leighxu 2006-10-26
  • 打赏
  • 举报
回复
怎么没人有呀??晕死..
leighxu 2006-10-25
  • 打赏
  • 举报
回复
因为都没科学计算的呀..还有就是没有进制的..呵..发给偶了.偶就会给分数的.呵..
股神 2006-10-25
  • 打赏
  • 举报
回复
up
zhangzengping 2006-10-25
  • 打赏
  • 举报
回复
我都给你发完了! 还出贴!
leighxu 2006-10-25
  • 打赏
  • 举报
回复
偶想要的是一个压缩包..因为偶当作业交了..
xiaohutushen 2006-10-25
  • 打赏
  • 举报
回复
接分
oolongTea 2006-10-25
  • 打赏
  • 举报
回复
http://www.csharpfriends.com/Members/main/tutorials/downloads/MosessaurCalculator.zip
oolongTea 2006-10-25
  • 打赏
  • 举报
回复
C# Calculator Using Windows Forms
By S. Thangaraju

This is a basic calculator program using Windows Forms. You will be able to do mathematical operations like addition,subtraction etc.

Source Code

using System;
using System.Windows.Forms;
using System.Drawing;

public class win:Form {

Button[] b = new Button[10];
Button bDot,bPlus,bSub,bMul,bDiv,bEqu,bClr;
Panel panCalc;
TextBox txtCalc;

Double dblAcc;
Double dblSec;
bool blnClear,blnFrstOpen;
String strOper;

public win() {
try {
this.Text="Calculator";
panCalc=new Panel();
txtCalc = new TextBox();

txtCalc.Location = new Point(10,10);
txtCalc.Size=new Size(150,10);
txtCalc.ReadOnly=true;
txtCalc.RightToLeft=RightToLeft.Yes;
panCalc.Size=new Size(200,200);
panCalc.BackColor=Color.Aqua;
panCalc.Controls.Add(txtCalc);
addButtons(panCalc);
this.Size=new Size(200,225);
this.Controls.Add(panCalc);

dblAcc=0;
dblSec=0;
blnFrstOpen=true;
blnClear=false;
strOper=new String('=',1);
}
catch (Exception e) {
Console.WriteLine("error ...... " + e.StackTrace);
}
}

private void addButtons(Panel p) {
for (int i=0;i<=9;i++) {
b[i]=new Button();
b[i].Text=Convert.ToString(i);
b[i].Size=new Size(25,25);
b[i].BackColor=Color.White;
b[i].Click+=new EventHandler(btn_clk);
p.Controls.Add(b[i]);
}
b[0].Location=new Point(10,160);
b[1].Location=new Point(10,120);
b[4].Location=new Point(10,80);
b[7].Location=new Point(10,40);

b[2].Location=new Point(50,120);
b[5].Location=new Point(50,80);
b[8].Location=new Point(50,40);

b[3].Location=new Point(90,120);
b[6].Location=new Point(90,80);
b[9].Location=new Point(90,40);

bDot=new Button();
bDot.Size=new Size(25,25);
bDot.Location=new Point(50,160);
bDot.BackColor=Color.White;
bDot.Text=".";
bDot.Click+=new EventHandler(btn_clk);

bPlus=new Button();
bPlus.Size=new Size(25,25);
bPlus.Location=new Point(130,160);
bPlus.BackColor=Color.White;
bPlus.Text="+";
bPlus.Click+=new EventHandler(btn_Oper);

bSub=new Button();
bSub.Size=new Size(25,25);
bSub.Location=new Point(130,120);
bSub.BackColor=Color.White;
bSub.Text="-";
bSub.Click+=new EventHandler(btn_Oper);

bMul=new Button();
bMul.Size=new Size(25,25);
bMul.Location=new Point(130,80);
bMul.BackColor=Color.White;
bMul.Text="*";
bMul.Click+=new EventHandler(btn_Oper);

bDiv=new Button();
bDiv.Size=new Size(25,25);
bDiv.Location=new Point(130,40);
bDiv.BackColor=Color.White;
bDiv.Text="/";
bDiv.Click+=new EventHandler(btn_Oper);

bEqu=new Button();
bEqu.Size=new Size(25,25);
bEqu.Location=new Point(90,160);
bEqu.BackColor=Color.White;
bEqu.Text="=";
bEqu.Click+=new EventHandler(btn_equ);

bClr=new Button();
bClr.Size=new Size(20,45);
bClr.Location=new Point(170,40);
bClr.BackColor=Color.Orange;
bClr.Text="AC";
bClr.Click+=new EventHandler(btn_clr);

p.Controls.Add(bDot);
p.Controls.Add(bPlus);
p.Controls.Add(bSub);
p.Controls.Add(bMul);
p.Controls.Add(bDiv);
p.Controls.Add(bEqu);
p.Controls.Add(bClr);
}

private void btn_clk(object obj,EventArgs ea) {
if(blnClear)
txtCalc.Text="";

Button b3=(Button)obj;

txtCalc.Text+=b3.Text;

if (txtCalc.Text==".")
txtCalc.Text="0.";
dblSec=Convert.ToDouble(txtCalc.Text);

blnClear=false;
}

private static void Main() {
Application.Run(new win());
}

private void btn_Oper(object obj,EventArgs ea) {
Button tmp=(Button)obj;
strOper=tmp.Text;
if (blnFrstOpen)
dblAcc=dblSec;
else
calc();

blnFrstOpen=false;
blnClear=true;
}

private void btn_clr(object obj,EventArgs ea) {
clear();
}

private void btn_equ(object obj,EventArgs ea) {
calc();

}

private void calc() {

switch(strOper) {

case "+":
dblAcc+=dblSec;
break;
case "-":
dblAcc-=dblSec;
break;
case "*":
dblAcc*=dblSec;
break;
case "/":
dblAcc/=dblSec;
break;
}

strOper="=";
blnFrstOpen=true;
txtCalc.Text=Convert.ToString(dblAcc);
dblSec=dblAcc;
}

private void clear() {
dblAcc=0;
dblSec=0;
blnFrstOpen=true;
txtCalc.Text="";
txtCalc.Focus();

}
}
发帖
C#

10.8w+

社区成员

.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
帖子事件
创建了帖子
2006-10-25 11:12
社区公告

让您成为最强悍的C#开发者