Fórum Criando uma função para digitar epenas números ???? #538367
27/11/2015
0
tenho vários edits onde só é permitido digitar número e venho utilizando esse código
If (DSCadPadrao.State in [dsEdit, dsInsert]) then
begin
//apenas numeros / enter / bacspace / tab / delete
if not (Key in['0'..'9', #13, #8, #9, #10 ]) then
Key := #0;
end;
isso está deixando o código gigante e confuso, gostaria de criar uma função com esse código
Emanuel Gonçalves
Curtir tópico
+ 0Posts
27/11/2015
Raimundo Pereira
[img]http://arquivo.devmedia.com.br/forum/imagem/437747-20151127-193817.png[/img]
Espero ter ajudado.
Gostei + 0
28/11/2015
Emanuel Gonçalves
Gostei + 0
28/11/2015
Dirceu Morais
Criei uma Unit com a função
function SomenteInteiro(var tecla : char) : boolean;
begin
if not (tecla in['0'..'9', #8, #13]) then begin
Beep();
Tecla := #0;
result := false;
end
else
result := true;
end;
Eu uso assim.
Uses MinhaUnit . . . .
No evento OnKeyPress
procedure TFormEventos.DBEdit1KeyPress(Sender: TObject; var Key: Char);
Begin
SomenteInteiro(key);
end;
Gostei + 0
28/11/2015
Emanuel Gonçalves
Criei uma Unit com a função
function SomenteInteiro(var tecla : char) : boolean;
begin
if not (tecla in['0'..'9', #8, #13]) then begin
Beep();
Tecla := #0;
result := false;
end
else
result := true;
end;
Eu uso assim.
Uses MinhaUnit . . . .
No evento OnKeyPress
procedure TFormEventos.DBEdit1KeyPress(Sender: TObject; var Key: Char);
Begin
SomenteInteiro(key);
end;
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)