Тема: Генератор паролів.
Можливо комусь знадобиться.
І якщо є якість поради по поліпшенню коду пишіть.
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Panel1: TPanel;
Button1: TButton;
Timer1: TTimer;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
procedure FormShow(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure RadioButton3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Z:integer; // z- кількість символів.
a,b,s:string;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled:=true;
edit1.Text:='';
end;
procedure TForm1.FormShow(Sender: TObject);
begin
z:=8;
s:='qwertyuiopasdfghjklzxcvbnm0123456789';
end;
procedure TForm1.RadioButton1Click(Sender: TObject);
begin
z:=8;
end;
procedure TForm1.RadioButton2Click(Sender: TObject);
begin
z:=16;
end;
procedure TForm1.RadioButton3Click(Sender: TObject);
begin
z:=32;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
randomize;
b:=(copy(s,random(length(s)),1));
a:=a+b;
edit1.text:=a;
if (length(edit1.text)=z) and (length(a)=z) then
begin
timer1.Enabled:=false;
a:='';
end;
end;
end.
[img]Snap 2015-05-16 at 18.30.05.png[/img]