Ver Mensaje Individual
  #1  
Antiguo 30-12-2020
AlejandroCalica AlejandroCalica is offline
Miembro
 
Registrado: nov 2020
Posts: 37
Reputación: 0
AlejandroCalica Va por buen camino
perfectooooooo....

Cita:
Empezado por kuan-yiu Ver Mensaje
Código Delphi [-]
case CB1 of
1: //Cachorro de 2  meses
   Gra:=StrToFloatDef(Edit1.Text,0) * 10 /100;

2: //Cachorro de 3 a 4 meses
   Gra:=StrToFloatDef(Edit1.Text,0) * 8 /100;

// y todas las demás opciones
else
   Gra:=1; // Para cubrir todos los casos
end;

Label5.Text:=FloattoStr(Gra);
Hc:=(Gra * 60 )/100;
Cm:=(Gra * 20) /100;
Ov:=(Gra * 10) /100;
Fv:=(Gra * 5) /100;
Sn:=(Gra * 5) /100;
Label9.Text:=FloattoStr(Hc)  ;
Label10.Text:=FloattoStr(Cm)  ;
Label11.Text:=FloattoStr(Ov)  ;
Label12.Text:=FloattoStr(Fv)  ;
Label13.Text:=FloattoStr(Sn)  ;

asi quedo al final

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
begin
CB1:=combobox1.ItemIndex+1;
case CB1 of
1: begin //Cachorro de 2  meses
   Gra:=StrToFloatDef(Edit1.Text,0) * 10 /100;
end;
2: begin //Cachorro de 3 a 4 meses
   Gra:=StrToFloatDef(Edit1.Text,0) * 8 /100;
end;
3:begin//Cachorro de 5 a 6 meses
  Gra:=StrToFloatDef(Edit1.Text,0) * 6 /100;
end;
4: begin //Cachorro de 7 a 8 año
   Gra:=StrToFloatDef(Edit1.Text,0) * 4 /100;
end;
5: begin //Cachorro de 9 a 10 año
   Gra:=StrToFloatDef(Edit1.Text,0) * 3 /100;
end;
6: begin //Cachorro de 11 a 12 año
   Gra:=StrToFloatDef(Edit1.Text,0) * 2 /100;
end;
7: begin //Adulto Actividad Alta
   Gra:=StrToFloatDef(Edit1.Text,0) * 4 /100;
end;
8: begin //Adulto Actividad Media
   Gra:=StrToFloatDef(Edit1.Text,0) * 3 /100;
end;
9: begin //Adulto Cedentario
   Gra:=StrToFloatDef(Edit1.Text,0) * 2.5 /100;
end;
10: begin //Esterilizada o Castrado
    Gra:=StrToFloatDef(Edit1.Text,0) * 2.5 /100;
end;
11: begin //Perro mayor de 6 años
    Gra:=StrToFloatDef(Edit1.Text,0) * 2 /100;
end else
   Gra:=1;
end;
Label5.Text:=FloattoStr(Gra);
Hc:=(Gra * 60 )/100;
Cm:=(Gra * 20) /100;
Ov:=(Gra * 10) /100;
Fv:=(Gra * 5) /100;
Sn:=(Gra * 5) /100;
Label9.Text:=FloattoStr(Hc)  ;
Label10.Text:=FloattoStr(Cm)  ;
Label11.Text:=FloattoStr(Ov)  ;
Label12.Text:=FloattoStr(Fv)  ;
Label13.Text:=FloattoStr(Sn)  ;
end;

se podra hacer mas compacto??????
Responder Con Cita