主题:附图片详细说明
eva83706009
[专家分:0] 发布于 2007-11-04 14:45:00
怎么用面向对象使得输入2个数相加??
回复列表 (共2个回复)
沙发
wjt132 [专家分:50] 发布于 2007-11-18 21:53:00
新建工程,最少加入6个组件:2个label、3个Edit和一个button
2个Label 中分别放置“+”“=”
3个Eidt
1个button用来求和,代码如下:
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Edit3->Text =(IntToStr)(StrToInt(Edit1->Text)+StrToInt(Edit2->Text));
}
//---------------------------------------------------------------------------
板凳
moke5 [专家分:30] 发布于 2010-09-01 14:43:00
你好.我是全职网赚工作者.
如果你有时间有电脑.会打字.
想在网络上创业.请联系我..
项目绝对真实.详情QQ空间资料
加盟请联系 QQ909065437
我来回复