Use Edit component for password
First of all, change PasswordChar property of Edit component that nobody saw your password, when you type it. In this example, length of password must be only 4 symbols.
procedure TForm1.Edit1Change(Sender: TObject); begin with Sender as TEdit do if Length(Text)>4 then begin Edit1.Text:=''; MessageBeep(0); end; end; procedure TForm1.Button1Click(Sender: TObject); begin MessageBox( Form1.Handle, PChar('You have just written - '+Edit1.Text), 'Password checking', 1); end;