Hi, 
I have a table in Excel with several rows and columns I want to transfer to 
Lazarus. I put in the form sgW: TStringGrid; when I am clicking on column 1 
must be calculated in column 2. But why add the values ​​of the last two rows 
of the second column in the first 2 rows of the 3rd? How can I do this 
calculations like in Excel? Here's sample code (PosW is var in the original 
program, here is an example constant):
 
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Grids;

type

  { TForm1 }

  TForm1 = class(TForm)
    sgW: TStringGrid;
    procedure sgWClick(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;


implementation

{$R *.lfm}


{ TForm1 }

procedure TForm1.sgWClick(Sender: TObject);
const
  PosW: array[1..12] of double = (90.2943201302, 72.4248719439,68.8869342366,
  45.2598466854,45.2598459837, 326.9552580449,165.9727037213,
  356.5835481932,326.3341381295, 272.031738496, 325.9835619548,211.4549241651);
var

  W: array[-1..12,-1..7] of double;
  i,j: integer;
  StrTest: string;
begin
  // Clear array
  for i := 1 to 12 do
   for j := 1 to 7 do Begin
     W[j,i] := 0.0;
     Str(W[j,i]:3:9,  StrTest);
     sgW.Cells[j,i] := StrTest;
   End;
  for i := 1 to 11 do Begin
    W[1,i] := PosW[i];
    W[2,i] := PosW[i] - PosW[12];
  End;
  for i := 1 to 12 do
   for j := 1 to 7 do Begin
     Str(W[j,i]:3:9,  StrTest);
     sgW.Cells[j,i] := StrTest;
   End;
end;

end.           
--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to