Hola amigos quisiera ver si alguien me puede ayudar con esto, mi problema es que a la hora de correrlo el resultado no me lo da como si lo hicieras a amano por favor ayuda. Les dejo mi código:
Código Delphi
[-]
unit Menu;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls, math;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Grid1: TStringGrid;
Button4: TButton;
Button7: TButton;
Button8: TButton;
Grid2: TStringGrid;
Button5: TButton;
Button6: TButton;
Edit1: TEdit;
Edit2: TEdit;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Button9: TButton;
Button10: TButton;
procedure Button10Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
letra,oper:Integer;
det1, det11,det2,det3,det21, det31, deter11,deter12, deter21, deter22, deterR,deterI, x1,x2:Real;
mag, mag1, mag2,ang,ang2, ang1, mag3,mag4,mag5,ang3,ang4,ang5:Real;
det4,det5,det6,det41,det51,det61:Real;
implementation
uses Rectang,Polar;
{$R *.dfm}
procedure TForm1.Button10Click(Sender: TObject);
begin
rid2.ColCount:=Grid2.ColCount-1;
Grid2.RowCount:=Grid2.RowCount-1;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Form2.ShowModal;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Form3.ShowModal;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
letra:=letra+1;
if letra<=90 then
begin
Grid1.RowCount:=Grid1.RowCount+1;
Grid1.Cells[0,Grid1.RowCount-1]:=chr(letra);
end
else
begin
letra:=90;
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
letra:=letra-1;
if letra>=65 then
begin
Grid1.RowCount:=Grid1.RowCount-1;
end
else
begin
letra:=65;
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if Grid2.RowCount=2 then
begin
Grid2.Cells[0,0]:=Grid1.Cells[1,1] + Grid1.Cells[2,1] + 'i';
Grid2.Cells[0,1]:=Grid1.Cells[1,2] + Grid1.Cells[2,2] + 'i';
Grid2.Cells[1,0]:=Grid1.Cells[1,3] + Grid1.Cells[2,3] + 'i';
Grid2.Cells[1,1]:=Grid1.Cells[1,4] + Grid1.Cells[2,4] + 'i';
Grid2.Cells[2,0]:=Grid1.Cells[1,5] + Grid1.Cells[2,5] + 'i';
Grid2.Cells[2,1]:=Grid1.Cells[1,6] + Grid1.Cells[2,6] + 'i';
end;
if Grid2.RowCount=3 then
begin
Grid2.Cells[0,0]:=Grid1.Cells[1,1] + Grid1.Cells[2,1] + 'i';
Grid2.Cells[0,1]:=Grid1.Cells[1,2] + Grid1.Cells[2,2] + 'i';
Grid2.Cells[0,2]:=Grid1.Cells[1,3] + Grid1.Cells[2,3] + 'i';
Grid2.Cells[1,0]:=Grid1.Cells[1,4] + Grid1.Cells[2,4] + 'i';
Grid2.Cells[1,1]:=Grid1.Cells[1,5] + Grid1.Cells[2,5] + 'i';
Grid2.Cells[1,2]:=Grid1.Cells[1,6] + Grid1.Cells[2,6] + 'i';
Grid2.Cells[2,0]:=Grid1.Cells[1,7] + Grid1.Cells[2,7] + 'i';
Grid2.Cells[2,1]:=Grid1.Cells[1,8] + Grid1.Cells[2,8] + 'i';
Grid2.Cells[2,2]:=Grid1.Cells[1,9] + Grid1.Cells[2,9] + 'i';
end;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
if Grid2.RowCount=2 then
begin
mag:=strtofloat(Grid1.Cells[3,1])*strtofloat(Grid1.Cells[3,4]);
ang:=strtofloat(Grid1.Cells[4,1])+ strtofloat(Grid1.Cells[4,4]);
mag1:=strtofloat(Grid1.Cells[3,2])*strtofloat(Grid1.Cells[3,3]);
ang1:=strtofloat(Grid1.Cells[4,2])+ strtofloat(Grid1.Cells[4,3]);
det1:=RoundTo(mag*cos(degtorad(ang)), -2);
det11:=RoundTo(mag*sin(degtorad(ang)), -2);
det2:=RoundTo(mag1*cos(degtorad(ang1)), -2);
det21:=RoundTo(mag1*sin(degtorad(ang1)), -2);
deter11:=det1-det2;
deter12:=det11-det21;
Edit1.Text:=floattostr(deter11);
Edit2.Text:=floattostr(deter12);
end;
if Grid2.RowCount=3 then
begin
mag:=(strtofloat(Grid1.Cells[3,1])*strtofloat(Grid1.Cells[3,5])*strtofloat(Grid1.Cells[3,9]));
ang:=(strtofloat(Grid1.Cells[4,1])+strtofloat(Grid1.Cells[4,5])+strtofloat(Grid1.Cells[4,9]));
mag1:=(strtofloat(Grid1.Cells[3,2])*strtofloat(Grid1.Cells[3,6])*strtofloat(Grid1.Cells[3,7]));
ang1:=(strtofloat(Grid1.Cells[4,2])+strtofloat(Grid1.Cells[4,6])+strtofloat(Grid1.Cells[4,7]));
mag2:=(strtofloat(Grid1.Cells[3,3])*strtofloat(Grid1.Cells[3,4])*strtofloat(Grid1.Cells[3,8]));
ang2:=(strtofloat(Grid1.Cells[4,3])+strtofloat(Grid1.Cells[4,4])+strtofloat(Grid1.Cells[4,8]));
det1:=RoundTo(mag*cos(degtorad(ang)), -2);
det11:=RoundTo(mag*sin(degtorad(ang)), -2);
det2:=RoundTo(mag1*cos(degtorad(ang1)), -2);
det21:=RoundTo(mag1*sin(degtorad(ang1)), -2);
det3:=RoundTo(mag2*cos(degtorad(ang2)), -2);
det31:=RoundTo(mag2*sin(degtorad(ang2)), -2);
deter11:=det1+det2+det3;
deter12:=det11+det21+det31;
mag3:=(strtofloat(Grid1.Cells[3,3])*strtofloat(Grid1.Cells[3,5])*strtofloat(Grid1.Cells[3,7]));
ang3:=(strtofloat(Grid1.Cells[4,3])+strtofloat(Grid1.Cells[4,5])+strtofloat(Grid1.Cells[4,7]));
mag4:=(strtofloat(Grid1.Cells[3,1])*strtofloat(Grid1.Cells[3,6])*strtofloat(Grid1.Cells[3,8]));
ang4:=(strtofloat(Grid1.Cells[4,1])+strtofloat(Grid1.Cells[4,6])+strtofloat(Grid1.Cells[4,8]));
mag5:=(strtofloat(Grid1.Cells[3,2])*strtofloat(Grid1.Cells[3,4])*strtofloat(Grid1.Cells[3,9]));
ang5:=(strtofloat(Grid1.Cells[4,2])+strtofloat(Grid1.Cells[4,4])+strtofloat(Grid1.Cells[4,9]));
det4:=RoundTo(mag3*cos(degtorad(ang3)), -2);
det41:=RoundTo(mag3*sin(degtorad(ang3)), -2);
det5:=RoundTo(mag4*cos(degtorad(ang4)), -2);
det51:=RoundTo(mag4*sin(degtorad(ang4)), -2);
det6:=RoundTo(mag5*cos(degtorad(ang5)), -2);
det61:=RoundTo(mag5*sin(degtorad(ang5)), -2);
deter21:=det4+det4+det6;
deter22:=det41+det51+det61;
deterR:=deter11-deter21;
deterI:=deter12-deter22;
Edit1.Text:=floattostr(deterR);
Edit2.Text:=floattostr(deterI);
end;
end;
procedure TForm1.Button7Click(Sender: TObject);
var
i:Integer;
begin
for i := 1 to Grid1.RowCount - 1 do
Grid1.Rows[i].Clear;
Grid1.Cells[0,1]:='A';
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
Self.Close;
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
Grid2.ColCount:=Grid2.ColCount+1;
Grid2.RowCount:=Grid2.RowCount+1;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
letra:=65;
Grid1.Cells[1,0]:='Real';
Grid1.Cells[2,0]:='Imag';
Grid1.Cells[3,0]:='Magnitud';
Grid1.Cells[4,0]:='Angulo';
Grid1.Cells[0,1]:=chr(letra);
oper:=0;
end;
end.