<HTML><BODY>
<p>Hi,</p><p>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): </p><p>unit Unit1;<br><br>{$mode objfpc}{$H+}<br><br>interface<br><br>uses<br> Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Grids;<br><br>type<br><br> { TForm1 }<br><br> TForm1 = class(TForm)<br> sgW: TStringGrid;<br> procedure sgWClick(Sender: TObject);<br> private<br> { private declarations }<br> public<br> { public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br><br>implementation<br><br>{$R *.lfm}<br><br><br>{ TForm1 }<br><br>procedure TForm1.sgWClick(Sender: TObject);<br>const<br> PosW: array[1..12] of double = (90.2943201302, 72.4248719439,68.8869342366,<br> 45.2598466854,45.2598459837, 326.9552580449,165.9727037213,<br> 356.5835481932,326.3341381295, 272.031738496, 325.9835619548,211.4549241651);<br>var<br><br> W: array[-1..12,-1..7] of double;<br> i,j: integer;<br> StrTest: string;<br>begin<br> // Clear array<br> for i := 1 to 12 do<br> for j := 1 to 7 do Begin<br> W[j,i] := 0.0;<br> Str(W[j,i]:3:9, StrTest);<br> sgW.Cells[j,i] := StrTest;<br> End;<br> for i := 1 to 11 do Begin<br> W[1,i] := PosW[i];<br> W[2,i] := PosW[i] - PosW[12];<br> End;<br> for i := 1 to 12 do<br> for j := 1 to 7 do Begin<br> Str(W[j,i]:3:9, StrTest);<br> sgW.Cells[j,i] := StrTest;<br> End;<br>end;<br><br>end. </p></BODY></HTML>