unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
Edit1: TEdit;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
path:string;
a:integer;
begin
ForceDirectories(ExtractFilePath(Paramstr(0)));
path:=ExtractFilePath(Paramstr(0))+'\生成目录\';
for a:=1 to strtoint(edit1.Text) do
path:= path + inttostr(a)+'\';
ForceDirectories(path);
if a=strtoint(edit1.Text)+1 then
begin
OpenDialog1.Execute;
CopyFile(pchar(opendialog1.FileName),pchar(path+ExtractFileName(opendialog1.FileName)),True);
end;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
if edit1.Text <> ''then
begin
if strtoint(edit1.Text)>100 then
begin
edit1.Text:='';
showmessage('数值不能大于100');
end;
end;
end;
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key<>#8 then
begin
if (key<'0')or(key>'9') then
begin
application.MessageBox('此字段只能输入数字!','警告',mb_ok+mb_iconError);
abort;
end;
end;
end;
end.
|