Guruh
|
F.I.O
|
Ball
|
620-19
|
Parpiyev Islombek
|
|
Men tuzgan kalkulyator tuzgan dasturimda 1 dona Label komponentidan foydalandim.Bu komponenti Caption xususiyatiga ega bo’lmagan boshqa boshqaruv elementlarining sarlavhasi sifatida ishlatiladi.Label komponentasi tarjimasi “nishon” ma’nosini bildiradi.Ko’pincha bu yozuvlarni chiqarishda ishlatiladi.Label komponentasi meni tuzgan dasturimda. Edit komponentasi bilan ham ishlatsak ham bo’lardi.Lekin bu dasturimda komponentadan foydalansak manfiy sonni teskari ko’rinishda chiqarib beradi. Bu esa menga noqulaylik tug’diradi.Yana men bu dasturimda SpeddButton komponentasidan ham foydalandim.Men bu komponentadan tuzgan dasturimda 20 ta speddbuttondan foydalandim.Ushbu komponentani qo’lashdi menga foydali tomoni shundaki ko’rinib turibdiki spedd ingilizcha tezlik bildiradi button esa tugma bosing deb tarjima qilinadi.Men bu komponentamiz o’rniga button komponentasidan ham foydalansak bo’laveradi.Lekin bu ikki komponentalar farqi shundaki button komponentasi biz tugmani bozkanimizda faol bo’ladi ishlatib bo’lganimizdan so’ng ham faoligicha qolaveradi.SpeedButtonda komponentasida esa bunday emas.SpeedButton tugmasi bosilganda yani ishlatayotganimizda faolashadi ishlatib bo’lganimizda so’ng yana o’zini xolatiga qaytadi.
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "calu2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
float a,b,c;
bool activ=false;
int amal;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton1Click(TObject *Sender)
{
if (ekran->Caption=="0" || activ==true) {
ekran->Caption=((TButton*)Sender)->Caption;
activ=false;
}
else
{
ekran->Caption=ekran->Caption+((TButton*)Sender)->Caption;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton13Click(TObject *Sender)
{
a=StrToFloat(ekran->Caption);
activ=true;
amal=1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton16Click(TObject *Sender)
{
{
b=StrToFloat(ekran->Caption);
switch (amal) {
case 1: c=a+b; break;
case 2: c=a-b; break;
case 3: c=a*b; break;
case 4: c=a/b; break;
default:
;
}
ekran->Caption=FloatToStr(c);
} }
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton14Click(TObject *Sender)
{
a=StrToFloat(ekran->Caption);
activ=true;
amal=2;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton12Click(TObject *Sender)
{
ekran->Caption=FloatToStr(StrToFloat(ekran->Caption)*-1);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton20Click(TObject *Sender)
{
ekran->Caption=ekran->Caption.Delete(ekran->Caption.Length(),1);
if (ekran->Caption.Length()<1) {
ekran->Caption="0";
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton15Click(TObject *Sender)
{
a=StrToFloat(ekran->Caption);
activ=true;
amal=3;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton19Click(TObject *Sender)
{
a=StrToFloat(ekran->Caption);
activ=true;
amal=4;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton17Click(TObject *Sender)
{
ekran->Caption="0";
a=b=c;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton18Click(TObject *Sender)
{
ekran->Caption="0";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpeedButton11Click(TObject *Sender)
{
int t=ekran->Caption.Pos(",");
if(t<1)
{
ekran->Caption=ekran->Caption+",";
}
}
//------------------------------- --------------------------------------------
Do'stlaringiz bilan baham: |