Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- {$mode objfpc}{$H+}
- interface
- uses
- Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
- Grids, StdCtrls, Spin;
- type
- { TForm1 }
- TForm1 = class(TForm)
- Button1: TButton;
- Button2: TButton;
- Button3: TButton;
- Edit1: TEdit;
- GroupBox1: TGroupBox;
- GroupBox2: TGroupBox;
- GroupBox3: TGroupBox;
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Panel1: TPanel;
- RadioButton1: TRadioButton;
- RadioButton2: TRadioButton;
- RadioButton3: TRadioButton;
- RadioGroup1: TRadioGroup;
- SpinEdit1: TSpinEdit;
- SpinEdit2: TSpinEdit;
- SpinEdit3: TSpinEdit;
- SpinEdit4: TSpinEdit;
- StringGrid1: TStringGrid;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure SpinEdit3Change(Sender: TObject);
- private
- { private declarations }
- public
- { public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- uses Unit2;
- {$R *.lfm}
- { TForm1 }
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- SpinEdit1.Value := StringGrid1.RowCount;
- SpinEdit2.Value := StringGrid1.ColCount;
- end;
- procedure TForm1.SpinEdit3Change(Sender: TObject);
- begin
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- StringGrid1.ColCount := SpinEdit2.Value;
- StringGrid1.RowCount := SpinEdit1.Value;
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- var i, ii: integer;
- begin
- Randomize;
- if (SpinEdit4.Value < SpinEdit3.Value) then
- ShowMessage('Error: wrong range') else
- begin
- for i := 0 to StringGrid1.ColCount - 1 do
- begin
- for ii := 0 to StringGrid1.RowCount - 1 do
- begin
- StringGrid1.Cells[i, ii] := IntToStr(Random(SpinEdit4.Value - SpinEdit3.Value + 1) + SpinEdit3.Value);
- end;
- end;
- end;
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- var i, ii, iii: integer;
- isFinded : boolean;
- location : String;
- begin
- if Edit1.Text = '' then
- begin
- ShowMessage('Error: enter the desired number')
- end else
- begin
- isFinded := false;
- if RadioButton1.Checked = true then
- begin
- for i := 0 to StringGrid1.RowCount - 1 do
- begin
- for ii := 0 to StringGrid1.ColCount - 1 do
- begin
- if (StringGrid1.Cells[ii, i] = (Edit1.Text)) then
- begin
- isFinded := true;
- Label3.Caption := ('Location: ' + IntToStr(i + 1) + ' ' + IntToStr(ii + 1));
- break;
- end;
- end;
- if isFinded then break;
- end;
- end;
- if RadioButton2.Checked = true then
- begin
- for i := StringGrid1.RowCount - 1 downto 0 do
- begin
- for ii := StringGrid1.ColCount - 1 downto 0 do
- begin
- if (StringGrid1.Cells[ii, i] = Edit1.Text) tuhen
- begin
- isFinded := true;
- Label3.Caption := ('Location: ' + IntToStr(i + 1) + ' ' + IntToStr(ii + 1));
- break;
- end;
- end;
- if isFinded then break;
- end;
- end;
- iii := 0;
- if RadioButton3.Checked = true then
- begin
- Form2.Show;
- Form2.Visible:=false;
- for i := 0 to StringGrid1.RowCount - 1 do
- begin
- for ii := 0 to StringGrid1.ColCount - 1 do
- begin
- if (StringGrid1.Cells[ii, i] = (Edit1.Text)) then
- begin
- Form2.Memo1.Lines[iii] := 'Location: ' + IntToStr(i + 1) + ' ' + IntToStr(ii + 1);
- iii += 1;
- end;
- end;
- end;
- Form2.ShowModal;
- end;
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment