Показать сообщение отдельно
  #1  
Старый 23.11.2011, 02:10
jie4e jie4e вне форума
Прохожий
 
Регистрация: 23.11.2011
Сообщения: 2
Репутация: 10
По умолчанию нужно вывести результат массива в F1Book1(ActiveX) наподобие как я вывел в StringGrid

используется f1book1, в принципе все есть, помогите пожалуйста!

Код:
function f1(x: real): real; 
begin 
f1 := cos(x) + 2; 
end; 

function f2(x: real): real; 
begin 
f2 := -1.2 * x + 5.8; 
end; 

procedure TForm1.fordo1Click(Sender: TObject); 
var 
N, i: integer; 
NRow: integer; 
begin 
SG1.Cells[0, 0] := '¹'; 
SG1.Cells[1, 0] := 'X'; 
SG1.Cells[2, 0] := 'Y'; 
NRow := 1; 

a := strtoint(edit1.Text); 
b := strtoint(edit2.Text); 
c := strtoint(edit3.Text); 
N := strtoint(edit4.Text); 
x := a; 
h := (b - a) / (N - 1); 

y := f1(x); 

SG1.Cells[0, Nrow] := IntToStr(NRow); 
SG1.Cells[1, Nrow] := format('%6.3f', [x]); 
SG1.Cells[2, Nrow] := Trim(format('%7.3f', [y])); 
SG1.RowCount := SG1.RowCount + 1; 
Inc(NRow); 

series1.AddXY(x, f1(x)); 
for i := 1 to (N - 1) do 
begin 
if x <= (c - h) then 
begin 
x := x + h; 
y := f1(x); 
series1.AddXY(x, f1(x)); 
end 
else 
begin 
x := x + h; 
y := f2(x); 
series2.AddXY(x, f2(x)); 
end; 

SG1.Cells[0, Nrow] := IntToStr(NRow); 
SG1.Cells[1, Nrow] := format('%6.3f', [x]); 
SG1.Cells[2, Nrow] := Trim(format('%7.3f', [y])); 
SG1.RowCount := SG1.RowCount + 1; 
Inc(NRow); 
end; 
label7.Visible := true; 
end; 

procedure TForm1.fx1Click(Sender: TObject); 
begin 
olecontainer1.Visible := true; 
end; 

procedure TForm1.Crepeatuntil1Click(Sender: TObject); 
var N: integer; 
begin 
a := strtoint(edit1.Text); 
b := strtoint(edit2.Text); 
c := strtoint(edit3.Text); 
N := strtoint(edit4.Text); 
x := a; 
h := (b - a) / (N - 1); 

y := f1(x); 

series3.AddXY(x, f1(x)); 
repeat 
x := x + h; 
if x <= c then 
begin 
y := f1(x); 
series3.AddXY(x, f1(x)); 
end 
else 
begin 
y := f2(x); series4.AddXY(x, f2(x)); 

end; 
until x >= (b - h); 
label7.Visible := true; 
end;
Ответить с цитированием