unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm2 = class(TForm) Edit1: TEdit; Button1: TButton; Label1: TLabel; Button2: TButton; procedure Edit1KeyPress(Sender: TObject; var Key: Char); procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation uses Unit1; {$R *.dfm} procedure TForm2.Edit1KeyPress(Sender: TObject; var Key: Char); begin if not(Key in['1','2','3','4','5','6','7','8','9','0',chr(8)]) then Key:=chr(0); end; procedure TForm2.Button1Click(Sender: TObject); begin if (Edit1.Text<>'') and (StrToInt(Edit1.Text)>2) and (StrToInt(Edit1.Text)<1001) then begin form1.knp:=StrToInt(Edit1.Text); form2.Close; end; end; procedure TForm2.Button2Click(Sender: TObject); begin Form1.cancel:=true; form2.Close; end; end.