1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| void __fastcall TForm1::Button2Click(TObject *Sender)
{
int p,m,s=0;
for( int k=0;k<Edit1->Text.ToInt();k++)
{
if(k+1+1> Edit1->Text.ToInt())
{
k+1+1=1;
p = StrToIntDef( ((TEdit*) FindComponent("myad" + IntToStr(k+1+1)))->Text, -1 )
- StrToIntDef( ((TEdit*) FindComponent("myad" + IntToStr(k+1-1)))->Text, -1 ) ;
m=(StrToIntDef (((TEdit*) FindComponent("myed" +IntToStr(k+1)))->Text, -1))*p;
Edit2->Text=IntToStr(s+m);
}
if (k+1-1=0)
{
(k+1-1)=Edit1->Text.ToInt();
p = StrToIntDef( ((TEdit*) FindComponent("myad" + IntToStr(k+1+1)))->Text, -1 )
- StrToIntDef( ((TEdit*) FindComponent("myad" + IntToStr(k+1-1)))->Text, -1 ) ;
m=(StrToIntDef (((TEdit*) FindComponent("myed" +IntToStr(k+1)))->Text, -1))*p;
Edit2->Text=IntToStr(s+m);
}
else
{
p = StrToIntDef( ((TEdit*) FindComponent("myad" + IntToStr(k+1+1)))->Text, -1 )
- StrToIntDef( ((TEdit*) FindComponent("myad" + IntToStr(k+1-1)))->Text, -1 ) ;
m=(StrToIntDef (((TEdit*) FindComponent("myed" +IntToStr(k+1)))->Text, -1))*p;
Edit2->Text=IntToStr(s+m);
}
} |
Partager