Digitar somente Letras!

Delphi

04/03/2004

Olá,


01) Como faço para permitir somente a digitação de letras no Edit?

02) Como faço para permitir somente a digitação de Números no Edit?



Atenciosamente


Motuca.


Motuca

Motuca

Curtidas 0

Respostas

Joilson_gouveia

Joilson_gouveia

04/03/2004

Use o evento onKeyPress, digitando o código abaixo:

-Só para Letras/Sinais:

if Pos(chr(key),´0123456789)>0 then
Key := #0;

-Só para Números:
if Pos(chr(key),´0123456789)=0 then
Key := 0;


GOSTEI 0
Fabio.hc

Fabio.hc

04/03/2004

Tente assim:

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
   if not(key in [´A´..´Z´,´a´..´z´]) then
      Key:=0;
end;

procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
   if not(key in [´0´..´9´]) then
      Key:=0;
end;



GOSTEI 0
Motuca

Motuca

04/03/2004

Muito obrigado!


GOSTEI 0
POSTAR