Delphi - Suma de valores de radiogroupbutton

   
Vista:

Suma de valores de radiogroupbutton

Publicado por Joan Carles (9 intervenciones) el 29/01/2013 12:06:49
Buenos días a todos/as,
Estoy realizando una pequeña aplicación con una serie de radiogroupbutton, a los cuales les asigno un valor y necesito que el valor total de la suma de todos los valores de los radiogroupbutton aparesca en un tdedit, el caso es que no consiguo que me realice la suma, alguien se le ocurre como se podria realizar la suma.
Gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Suma de valores de radiogroupbutton

Publicado por nombre (484 intervenciones) el 30/01/2013 23:20:47
Que significa que no consigues que realice la suma, explicate bien, como lo haces y que es lo que no sale.

Porque a simple vista parece simple, recorres los radiobutton, coges el valor que le has asignado a cada uno y lo vas sumando.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

Suma de valores de radiogroupbutton

Publicado por Joan Carles joancmb@yahoo.es (9 intervenciones) el 19/03/2013 13:50:01
Hola a todos y gracias por vuestra ayuda, aquí dejo la solución que he aplicado:
[DELPHI]
unit eqt;

interface

uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Imaging.jpeg, Vcl.ExtCtrls,
Vcl.StdCtrls, Vcl.DBCtrls, Vcl.Mask, Unit2;

type
TForm12 = class(TForm)
Label2: TLabel;
logo: TImage;
Label7: TLabel;
DBRadioGroup1: TDBRadioGroup;
DBRadioGroup2: TDBRadioGroup;
DBRadioGroup3: TDBRadioGroup;
DBRadioGroup4: TDBRadioGroup;
DBRadioGroup5: TDBRadioGroup;
DBRadioGroup6: TDBRadioGroup;
DBRadioGroup7: TDBRadioGroup;
DBRadioGroup8: TDBRadioGroup;
DBRadioGroup9: TDBRadioGroup;
Label1: TLabel;
DBEdit1: TDBEdit;
Button1: TButton;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure DBRadioGroup1Change(Sender: TObject);
procedure DBRadioGroup2Change(Sender: TObject);
procedure DBRadioGroup3Change(Sender: TObject);
procedure DBRadioGroup4Change(Sender: TObject);
procedure DBRadioGroup5Change(Sender: TObject);
procedure DBRadioGroup6Change(Sender: TObject);
procedure DBRadioGroup7Change(Sender: TObject);
procedure DBRadioGroup8Change(Sender: TObject);
procedure DBRadioGroup9Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form12: TForm12;

implementation

{$R *.dfm}

procedure TForm12.Button2Click(Sender: TObject);
begin
Close;
end;

procedure TForm12.DBRadioGroup1Change(Sender: TObject);
begin
//showmessage(form12.DBRadioGroup1.Value);
//showmessage(form12.DBRadioGroup2.Value);
//form12.DBEdit1.Text := string(form12.DBRadioGroup1.Value) + string(form12.DBRadioGroup2.Value);
//form12.DBEdit1.Text := IntToStr(TryStrToInt(form12.DBRadioGroup1.Value)+ StrToInt(form12.DBRadioGroup2.Value)+ StrToInt(form12.DBRadioGroup3.Value) + StrToInt(form12.DBRadioGroup4.Value) + StrToInt(form12.DBRadioGroup5.Value) + StrToInt(form12.DBRadioGroup6.Value) + StrToInt(form12.DBRadioGroup7.Value)+ StrToInt(form12.DBRadioGroup8.Value)+ StrToInt(form12.DBRadioGroup9.Value));
//form12.DBEdit1.Text := IntToStr(StrToInt(form12.DBRadioGroup1.Value) + StrToInt(form12.DBRadioGroup2.Value) + StrToInt(form12.DBRadioGroup3.Value));
if (form12.DBRadioGroup1.Value <> '') and (form12.DBRadioGroup2.Value <> '') and (form12.DBRadioGroup3.Value <> '') and (form12.DBRadioGroup4.Value <> '') and (form12.DBRadioGroup5.Value <> '') and (form12.DBRadioGroup6.Value <> '')and (form12.DBRadioGroup7.Value <> '') and (form12.DBRadioGroup8.Value <> '') and (form12.DBRadioGroup9.Value <> '') then
form12.DBEdit1.Text := inttostr(strtoint(form12.DBRadioGroup1.Value) + strtoint(form12.DBRadioGroup2.Value) + strtoint(form12.DBRadioGroup3.Value) + strtoint(form12.DBRadioGroup4.Value) + strtoint(form12.DBRadioGroup5.Value) + strtoint(form12.DBRadioGroup6.Value) + strtoint(form12.DBRadioGroup7.Value) + strtoint(form12.DBRadioGroup8.Value) + strtoint(form12.DBRadioGroup9.Value));

end;

procedure TForm12.DBRadioGroup2Change(Sender: TObject);
begin
if (form12.DBRadioGroup1.Value <> '') and (form12.DBRadioGroup2.Value <> '') and (form12.DBRadioGroup3.Value <> '') and (form12.DBRadioGroup4.Value <> '') and (form12.DBRadioGroup5.Value <> '') and (form12.DBRadioGroup6.Value <> '')and (form12.DBRadioGroup7.Value <> '') and (form12.DBRadioGroup8.Value <> '') and (form12.DBRadioGroup9.Value <> '') then
form12.DBEdit1.Text := IntToStr(StrToInt(form12.DBRadioGroup2.Value)+ StrToInt(form12.DBRadioGroup1.Value) + StrToInt(form12.DBRadioGroup3.Value) + StrToInt(form12.DBRadioGroup4.Value) + StrToInt(form12.DBRadioGroup5.Value) + StrToInt(form12.DBRadioGroup6.Value) + StrToInt(form12.DBRadioGroup7.Value) + StrToInt(form12.DBRadioGroup8.Value)+ StrToInt(form12.DBRadioGroup9.Value));
// form12.DBEdit1.Text := form12.DBRadioGroup1.Value + form12.DBRadioGroup2.Value + form12.DBRadioGroup3.Value;
end;

procedure TForm12.DBRadioGroup3Change(Sender: TObject);
begin
if (form12.DBRadioGroup1.Value <> '') and (form12.DBRadioGroup2.Value <> '') and (form12.DBRadioGroup3.Value <> '') and (form12.DBRadioGroup4.Value <> '') and (form12.DBRadioGroup5.Value <> '') and (form12.DBRadioGroup6.Value <> '')and (form12.DBRadioGroup7.Value <> '') and (form12.DBRadioGroup8.Value <> '') and (form12.DBRadioGroup9.Value <> '') then
form12.DBEdit1.Text := IntToStr(StrToInt(form12.DBRadioGroup3.Value)+ StrToInt(form12.DBRadioGroup1.Value) + StrToInt(form12.DBRadioGroup2.Value) + StrToInt(form12.DBRadioGroup4.Value) + StrToInt(form12.DBRadioGroup5.Value) + StrToInt(form12.DBRadioGroup6.Value)+ StrToInt(form12.DBRadioGroup7.Value) + StrToInt(form12.DBRadioGroup8.Value) + StrToInt(form12.DBRadioGroup9.Value));
//form12.DBEdit1.Text := form12.DBRadioGroup1.Value + form12.DBRadioGroup2.Value + form12.DBRadioGroup3.Value;
end;

procedure TForm12.DBRadioGroup4Change(Sender: TObject);
begin
if (form12.DBRadioGroup1.Value <> '') and (form12.DBRadioGroup2.Value <> '') and (form12.DBRadioGroup3.Value <> '') and (form12.DBRadioGroup4.Value <> '') and (form12.DBRadioGroup5.Value <> '') and (form12.DBRadioGroup6.Value <> '')and (form12.DBRadioGroup7.Value <> '') and (form12.DBRadioGroup8.Value <> '') and (form12.DBRadioGroup9.Value <> '') then
form12.DBEdit1.Text := IntToStr(StrToInt(form12.DBRadioGroup4.Value)+ StrToInt(form12.DBRadioGroup1.Value) + StrToInt(form12.DBRadioGroup2.Value) + StrToInt(form12.DBRadioGroup3.Value) + StrToInt(form12.DBRadioGroup5.Value) + StrToInt(form12.DBRadioGroup6.Value)+ StrToInt(form12.DBRadioGroup7.Value) + StrToInt(form12.DBRadioGroup8.Value) + StrToInt(form12.DBRadioGroup9.Value));
//form12.DBEdit1.Text := form12.DBRadioGroup1.Value + form12.DBRadioGroup2.Value + form12.DBRadioGroup3.Value;
end;

procedure TForm12.DBRadioGroup5Change(Sender: TObject);
begin
if (form12.DBRadioGroup1.Value <> '') and (form12.DBRadioGroup2.Value <> '') and (form12.DBRadioGroup3.Value <> '') and (form12.DBRadioGroup4.Value <> '') and (form12.DBRadioGroup5.Value <> '') and (form12.DBRadioGroup6.Value <> '')and (form12.DBRadioGroup7.Value <> '') and (form12.DBRadioGroup8.Value <> '') and (form12.DBRadioGroup9.Value <> '') then
form12.DBEdit1.Text := IntToStr(StrToInt(form12.DBRadioGroup5.Value)+ StrToInt(form12.DBRadioGroup1.Value) + StrToInt(form12.DBRadioGroup2.Value) + StrToInt(form12.DBRadioGroup3.Value) + StrToInt(form12.DBRadioGroup4.Value) + StrToInt(form12.DBRadioGroup6.Value)+ StrToInt(form12.DBRadioGroup7.Value) + StrToInt(form12.DBRadioGroup8.Value) + StrToInt(form12.DBRadioGroup9.Value));
//form12.DBEdit1.Text := form12.DBRadioGroup1.Value + form12.DBRadioGroup2.Value + form12.DBRadioGroup3.Value;
end;

procedure TForm12.DBRadioGroup6Change(Sender: TObject);
begin
if (form12.DBRadioGroup1.Value <> '') and (form12.DBRadioGroup2.Value <> '') and (form12.DBRadioGroup3.Value <> '') and (form12.DBRadioGroup4.Value <> '') and (form12.DBRadioGroup5.Value <> '') and (form12.DBRadioGroup6.Value <> '')and (form12.DBRadioGroup7.Value <> '') and (form12.DBRadioGroup8.Value <> '') and (form12.DBRadioGroup9.Value <> '') then
form12.DBEdit1.Text := IntToStr(StrToInt(form12.DBRadioGroup6.Value)+ StrToInt(form12.DBRadioGroup1.Value) + StrToInt(form12.DBRadioGroup2.Value) + StrToInt(form12.DBRadioGroup3.Value) + StrToInt(form12.DBRadioGroup5.Value) + StrToInt(form12.DBRadioGroup4.Value)+ StrToInt(form12.DBRadioGroup7.Value) + StrToInt(form12.DBRadioGroup8.Value) + StrToInt(form12.DBRadioGroup9.Value));
//form12.DBEdit1.Text := form12.DBRadioGroup1.Value + form12.DBRadioGroup2.Value + form12.DBRadioGroup3.Value;
end;

procedure TForm12.DBRadioGroup7Change(Sender: TObject);
begin
if (form12.DBRadioGroup1.Value <> '') and (form12.DBRadioGroup2.Value <> '') and (form12.DBRadioGroup3.Value <> '') and (form12.DBRadioGroup4.Value <> '') and (form12.DBRadioGroup5.Value <> '') and (form12.DBRadioGroup6.Value <> '')and (form12.DBRadioGroup7.Value <> '') and (form12.DBRadioGroup8.Value <> '') and (form12.DBRadioGroup9.Value <> '') then
form12.DBEdit1.Text := IntToStr(StrToInt(form12.DBRadioGroup7.Value)+ StrToInt(form12.DBRadioGroup1.Value) + StrToInt(form12.DBRadioGroup2.Value) + StrToInt(form12.DBRadioGroup3.Value) + StrToInt(form12.DBRadioGroup5.Value) + StrToInt(form12.DBRadioGroup6.Value)+ StrToInt(form12.DBRadioGroup4.Value) + StrToInt(form12.DBRadioGroup8.Value) + StrToInt(form12.DBRadioGroup9.Value));
//form12.DBEdit1.Text := form12.DBRadioGroup1.Value + form12.DBRadioGroup2.Value + form12.DBRadioGroup3.Value;
end;

procedure TForm12.DBRadioGroup8Change(Sender: TObject);
begin
if (form12.DBRadioGroup1.Value <> '') and (form12.DBRadioGroup2.Value <> '') and (form12.DBRadioGroup3.Value <> '') and (form12.DBRadioGroup4.Value <> '') and (form12.DBRadioGroup5.Value <> '') and (form12.DBRadioGroup6.Value <> '')and (form12.DBRadioGroup7.Value <> '') and (form12.DBRadioGroup8.Value <> '') and (form12.DBRadioGroup9.Value <> '') then
form12.DBEdit1.Text := IntToStr(StrToInt(form12.DBRadioGroup8.Value)+ StrToInt(form12.DBRadioGroup1.Value) + StrToInt(form12.DBRadioGroup2.Value) + StrToInt(form12.DBRadioGroup3.Value) + StrToInt(form12.DBRadioGroup5.Value) + StrToInt(form12.DBRadioGroup6.Value)+ StrToInt(form12.DBRadioGroup7.Value) + StrToInt(form12.DBRadioGroup4.Value) + StrToInt(form12.DBRadioGroup9.Value));
//form12.DBEdit1.Text := form12.DBRadioGroup1.Value + form12.DBRadioGroup2.Value + form12.DBRadioGroup3.Value;
end;

procedure TForm12.DBRadioGroup9Change(Sender: TObject);
begin
if (form12.DBRadioGroup1.Value <> '') and (form12.DBRadioGroup2.Value <> '') and (form12.DBRadioGroup3.Value <> '') and (form12.DBRadioGroup4.Value <> '') and (form12.DBRadioGroup5.Value <> '') and (form12.DBRadioGroup6.Value <> '')and (form12.DBRadioGroup7.Value <> '') and (form12.DBRadioGroup8.Value <> '') and (form12.DBRadioGroup9.Value <> '') then
form12.DBEdit1.Text := IntToStr(StrToInt(form12.DBRadioGroup9.Value)+ StrToInt(form12.DBRadioGroup1.Value) + StrToInt(form12.DBRadioGroup2.Value) + StrToInt(form12.DBRadioGroup3.Value) + StrToInt(form12.DBRadioGroup5.Value) + StrToInt(form12.DBRadioGroup6.Value)+ StrToInt(form12.DBRadioGroup7.Value) + StrToInt(form12.DBRadioGroup8.Value) + StrToInt(form12.DBRadioGroup4.Value));
//form12.DBEdit1.Text := form12.DBRadioGroup1.Value + form12.DBRadioGroup2.Value + form12.DBRadioGroup3.Value;
end;

end.
[/DELPHI]

Gracias por vuestra ayuda.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar