En realidad el programa lo tengo actualmente asi y es peor, es repetitivo,
son 20 edit.
Código Delphi
[-]
procedure TForm1.Button3Click(Sender: TObject);
begin
Timer1.Enabled:= False;
if ComboBox3.Text = 'Sumar' Then
Edit4.Text := FloatToStr(StrToFloat(ComboBox4.Text) + StrToFloat(ComboBox5.Text));
If Edit3.Text <> Edit4.Text Then
Label4.Color:= CLRed;
Label4.Caption:= 'X';
If Edit3.Text = Edit4.Text Then
Label4.Color:= CLLime;
Label4.Caption:= 'OK';
if ComboBox3.Text = 'Sumar' Then
Edit6.Text := FloatToStr(StrToFloat(ComboBox6.Text) + StrToFloat(ComboBox7.Text));
If Edit5.Text <> Edit6.Text Then
Label5.Color:= CLRed;
Label5.Caption:= 'X';
If Edit5.Text = Edit6.Text Then
Label5.Color:= CLLime;
Label5.Caption:= 'OK';
if ComboBox3.Text = 'Sumar' Then
Edit8.Text := FloatToStr(StrToFloat(ComboBox8.Text) + StrToFloat(ComboBox9.Text));
If Edit7.Text <> Edit8.Text Then
Label6.Color:= CLRed;
Label6.Caption:= 'X';
If Edit7.Text = Edit8.Text Then
Label6.Color:= CLLime;
Label6.Caption:= 'OK';
if ComboBox3.Text = 'Sumar' Then
Edit10.Text := FloatToStr(StrToFloat(ComboBox10.Text) + StrToFloat(ComboBox11.Text));
If Edit9.Text <> Edit10.Text Then
Label7.Color:= CLRed;
Label7.Caption:= 'X';
If Edit9.Text = Edit10.Text Then
Label7.Color:= CLLime;
Label7.Caption:= 'OK';
if ComboBox3.Text = 'Sumar' Then
Edit12.Text := FloatToStr(StrToFloat(ComboBox12.Text) + StrToFloat(ComboBox13.Text));
If Edit11.Text <> Edit12.Text Then
Label8.Color:= CLRed;
Label8.Caption:= 'X';
If Edit11.Text = Edit12.Text Then
Label8.Color:= CLLime;
Label8.Caption:= 'OK';
if ComboBox3.Text = 'Sumar' Then
Edit14.Text := FloatToStr(StrToFloat(ComboBox14.Text) + StrToFloat(ComboBox15.Text));
If Edit13.Text <> Edit14.Text Then
Label9.Color:= CLRed;
Label9.Caption:= 'X';
If Edit13.Text = Edit14.Text Then
Label9.Color:= CLLime;
Label9.Caption:= 'OK';
if ComboBox3.Text = 'Sumar' Then
Edit16.Text := FloatToStr(StrToFloat(ComboBox16.Text) + StrToFloat(ComboBox17.Text));
If Edit15.Text <> Edit16.Text Then
Label10.Color:= CLRed;
Label10.Caption:= 'X';
If Edit15.Text = Edit16.Text Then
Label10.Color:= CLLime;
Label10.Caption:= 'OK';
if ComboBox3.Text = 'Sumar' Then
Edit18.Text := FloatToStr(StrToFloat(ComboBox18.Text) + StrToFloat(ComboBox19.Text));
If Edit17.Text <> Edit18.Text Then
Label11.Color:= CLRed;
Label11.Caption:= 'X';
If Edit17.Text = Edit18.Text Then
Label11.Color:= CLLime;
Label11.Caption:= 'OK';
if ComboBox3.Text = 'Sumar' Then
Edit20.Text := FloatToStr(StrToFloat(ComboBox20.Text) + StrToFloat(ComboBox21.Text));
If Edit19.Text <> Edit20.Text Then
Label12.Color:= CLRed;
Label12.Caption:= 'X';
If Edit19.Text = Edit20.Text Then
Label12.Color:= CLLime;
Label12.Caption:= 'OK';
if ComboBox3.Text = 'Sumar' Then
Edit22.Text := FloatToStr(StrToFloat(ComboBox22.Text) + StrToFloat(ComboBox23.Text));
If Edit21.Text <> Edit22.Text Then
Label13.Color:= CLRed;
Label13.Caption:= 'X';
If Edit21.Text = Edit22.Text Then
Label13.Color:= CLLime;
Label13.Caption:= 'OK';
if ComboBox3.Text = 'Restar' Then
Edit4.Text := FloatToStr(StrToFloat(ComboBox4.Text) - StrToFloat(ComboBox5.Text));
If Edit3.Text <> Edit4.Text Then
Label4.Color:= CLRed;
Label4.Caption:= 'X';
If Edit3.Text = Edit4.Text Then
Label4.Color:= CLLime;
Label4.Caption:= 'OK';
if ComboBox3.Text = 'Restar' Then
Edit6.Text := FloatToStr(StrToFloat(ComboBox6.Text) - StrToFloat(ComboBox7.Text));
If Edit5.Text <> Edit6.Text Then
Label5.Color:= CLRed;
Label5.Caption:= 'X';
If Edit5.Text = Edit6.Text Then
Label5.Color:= CLLime;
Label5.Caption:= 'OK';
if ComboBox3.Text = 'Restar' Then
Edit8.Text := FloatToStr(StrToFloat(ComboBox8.Text) - StrToFloat(ComboBox9.Text));
If Edit7.Text <> Edit8.Text Then
Label6.Color:= CLRed;
Label6.Caption:= 'X';
If Edit7.Text = Edit8.Text Then
Label6.Color:= CLLime;
Label6.Caption:= 'OK';
if ComboBox3.Text = 'Restar' Then
Edit10.Text := FloatToStr(StrToFloat(ComboBox10.Text) - StrToFloat(ComboBox11.Text));
If Edit9.Text <> Edit10.Text Then
Label7.Color:= CLRed;
Label7.Caption:= 'X';
If Edit9.Text = Edit10.Text Then
Label7.Color:= CLLime;
Label7.Caption:= 'OK';
if ComboBox3.Text = 'Restar' Then
Edit12.Text := FloatToStr(StrToFloat(ComboBox12.Text) - StrToFloat(ComboBox13.Text));
If Edit11.Text <> Edit12.Text Then
Label8.Color:= CLRed;
Label8.Caption:= 'X';
If Edit11.Text = Edit12.Text Then
Label8.Color:= CLLime;
Label8.Caption:= 'OK';
if ComboBox3.Text = 'Restar' Then
Edit14.Text := FloatToStr(StrToFloat(ComboBox14.Text) - StrToFloat(ComboBox15.Text));
If Edit13.Text <> Edit14.Text Then
Label9.Color:= CLRed;
Label9.Caption:= 'X';
If Edit13.Text = Edit14.Text Then
Label9.Color:= CLLime;
Label9.Caption:= 'OK';
if ComboBox3.Text = 'Restar' Then
Edit16.Text := FloatToStr(StrToFloat(ComboBox16.Text) - StrToFloat(ComboBox17.Text));
If Edit15.Text <> Edit16.Text Then
Label10.Color:= CLRed;
Label10.Caption:= 'X';
If Edit15.Text = Edit16.Text Then
Label10.Color:= CLLime;
Label10.Caption:= 'OK';
if ComboBox3.Text = 'Restar' Then
Edit18.Text := FloatToStr(StrToFloat(ComboBox18.Text) - StrToFloat(ComboBox19.Text));
If Edit17.Text <> Edit18.Text Then
Label11.Color:= CLRed;
Label11.Caption:= 'X';
If Edit17.Text = Edit18.Text Then
Label11.Color:= CLLime;
Label11.Caption:= 'OK';
if ComboBox3.Text = 'Restar' Then
Edit20.Text := FloatToStr(StrToFloat(ComboBox20.Text) - StrToFloat(ComboBox21.Text));
If Edit19.Text <> Edit20.Text Then
Label12.Color:= CLRed;
Label12.Caption:= 'X';
If Edit19.Text = Edit20.Text Then
Label12.Color:= CLLime;
Label12.Caption:= 'OK';
if ComboBox3.Text = 'Restar' Then
Edit22.Text := FloatToStr(StrToFloat(ComboBox22.Text) - StrToFloat(ComboBox23.Text));
If Edit21.Text <> Edit22.Text Then
Label13.Color:= CLRed;
Label13.Caption:= 'X';
If Edit21.Text = Edit22.Text Then
Label13.Color:= CLLime;
Label13.Caption:= 'OK';
Y no puse las multiplicaciones y divisiones, si no seria mas codigo repetido.
Como simplifico esto ?
Saludos