Autor Beitrag
Delphi~Anfänger
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97



BeitragVerfasst: Do 03.06.04 19:04 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Edit1KeyPress(sender: TObject; var key: Char);
begin
  if not (key in [#8, #9, #48 .. #57]) then key:=#0;
end;


Das ist der Code um in einem Edit-Feld nur zahlen zulässen.
kann mir wer sagen was daran nicht stimmt (oder wie er richtig heißt).
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Do 03.06.04 19:17 
Hallo,

So sollte es gehen:
ausblenden Delphi-Quelltext
1:
  if not (key in [#8, #9, '0'..'9']) then key:=#0;					


Denke daran, '+', '-' und 'e' sind auch gültige Zeichen ;-)

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)