Czy to ma wyglądać tak?
1:
procedure TForm2.Edit1Change(Sender: TObject);
begin
for i := 0 to StringGrid.Cols - 1 do
StringGrid.Cells[i, 0] := StrToInt(i);
end;
Jeśli wkleje to do edit1 to wyświetla mi błąd:
Unit2.pas(42): Undeclared identifier: 'i'
rozumiem że brakuje zmiennej. No to przed begin wpisuje
var
i:integer;
lecz to nic nie daje poza tym że zmienia się błąd na:
Unit2.pas(41): Unknown directive: 'i'
wydaje mi się też, że w miejscach gdzie wpisałeś StringGrid powinno być StringGrid1
poza tym wyświetla mi się błąd:
[Error] Unit2.pas(43): 'DO' expected but identifier 'Cols' found
2:
Ten drugi kod wklejam do StringGrid1:
procedure TForm1.StringGrid1Click(Sender: TObject);
begin
Stringgrid1.Cells[0,0]:='DATA';
Stringgrid1.Cells[1,0]:='DYSTANS';
Stringgrid1.Cells[2,0]:='CZAS';
for i := 0 to StringGrid.Cols - 1 do
begin
Suma := 0;
for j := 1 to StringGrid.Rows - 2 do
Suma := Suma + StrToInt(StringGrid.Cells[i, j];
StringGrid.Cells[i, StrinGrid.Rows - 1] := IntToStr(Suma);
end;
powtarzają się błędy tak jakie jak:
Build
[Error] Unit1.pas(134): Undeclared identifier: 'i'
[Error] Unit1.pas(134): 'DO' expected but identifier 'Cols' found
[Error] Unit1.pas(136): Undeclared identifier: 'Suma'
[Error] Unit1.pas(137): Undeclared identifier: 'j'
[Error] Unit1.pas(137): 'DO' expected but identifier 'Rows' found
Już się pogubiłem. Prubowałem wprowadzać:
var
i:integer;
j:integer;
suma:integer;
ale to też nic nie dało.
Po zmodyfikowaniu fragmentu:
for i := 0 to StringGrid.Cols - 1 do
na:
for i := 0 to StringGrid1.Cols - 1 do
to wyskakuje kolejny błąd:
Unit1.pas(138): '[' expected but '-' found
No to rozumiem, że trzeba zmienic kod na jakoś tak:
<code>for i := 0 to StringGrid1.Cols [-1] do
No to wyskakuje kolejny błąd... :
Unit1.pas(138): Incompatible types: 'Integer' and 'TStrings'
mam już dosc tego kombinoiwania...
Zamieszczam kody 2 form z którymi mam problemy:
Forma 1:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, ExtCtrls, Grids, ComCtrls, ValEdit;
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
plik1: TMenuItem;
Zapisz1: TMenuItem;
Wczytaj1: TMenuItem;
Zakocz1: TMenuItem;
Info1: TMenuItem;
Oprogramie1: TMenuItem;
Button1: TButton;
Button2: TButton;
Button3: TButton;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
linkisponsorowane1: TMenuItem;
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
SaveDialog1: TSaveDialog;
OpenDialog1: TOpenDialog;
Button4: TButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
RadioButton5: TRadioButton;
RadioButton6: TRadioButton;
StringGrid1: TStringGrid;
procedure Zakocz1Click(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Oprogramie1Click(Sender: TObject);
procedure linkisponsorowane1Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure RadioButton3Click(Sender: TObject);
procedure RadioButton4Click(Sender: TObject);
procedure RadioButton5Click(Sender: TObject);
procedure RadioButton6Click(Sender: TObject);
procedure StringGrid1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2, Unit3, Unit5, Unit4;
{$R *.dfm}
procedure TForm1.Zakocz1Click(Sender: TObject);
begin
form3.showmodal;
end;
procedure TForm1.RadioButton1Click(Sender: TObject);
begin
if RadioButton1.Checked then
label1.Caption:=('Całkowity dystans:');
label3.Caption:=('KM');
end;
procedure TForm1.RadioButton2Click(Sender: TObject);
begin
if RadioButton2.Checked then
label1.Caption:=('Całkowity czas:');
label3.Caption:=('H');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
form2.showmodal;
end;
procedure TForm1.Oprogramie1Click(Sender: TObject);
begin
form5.showmodal;
end;
procedure TForm1.linkisponsorowane1Click(Sender: TObject);
begin
form4.showmodal;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
form3.showmodal;
end;
procedure TForm1.RadioButton3Click(Sender: TObject);
begin
if RadioButton3.Checked then
label1.Caption:=('Całkowita prędkosc srednia:');
label3.Caption:=('KM/H');
end;
procedure TForm1.RadioButton4Click(Sender: TObject);
begin
if RadioButton4.Checked then
label1.Caption:=('Dzienny dystans:');
label3.Caption:=('KM');
end;
procedure TForm1.RadioButton5Click(Sender: TObject);
begin
if RadioButton5.Checked then
label1.Caption:=('Dzienny czas:');
label3.Caption:=('H');
end;
procedure TForm1.RadioButton6Click(Sender: TObject);
begin
if RadioButton6.Checked then
label1.Caption:=('Dzienna prędkosc srednia:');
label3.Caption:=('KM/H');
end;
procedure TForm1.StringGrid1Click(Sender: TObject);
begin
Stringgrid1.Cells[0,0]:='DATA';
Stringgrid1.Cells[1,0]:='DYSTANS';
Stringgrid1.Cells[2,0]:='CZAS';
end;
end.
Forma 2:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, Calendar, ComCtrls;
type
TForm2 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
MonthCalendar1: TMonthCalendar;
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.Button2Click(Sender: TObject);
begin
close;
end;
end.