Autor Beitrag
schlumsch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122

alles Win :)
Delphi 2005 Prof, Delphi 2007
BeitragVerfasst: Mi 28.10.09 23:00 
Hallo,

ich habe 2 Edit oder auch Maskedit felder. In einem Fald sollen nur Buchstaben, im anderen Feld nur Zahlen erlaubt sein. Nun habe ich folgende Lösung gefunden:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.EditNewIntervallKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if not (Key in ['0'..'9'','#8]) then // #8 ist die Backspace Taste
    Key := #0;
end;

Hier kriege ich allerdings die Fehlermeldung: Inkompatible Typen Word und Char. Wie kann ich das lösen bzw. gibt es eine andere Möglichkeit die oben genannten einschränkungen zu treffen?

dank euch schon einmal, lg

Moderiert von user profile iconNarses: Code- durch Delphi-Tags ersetzt
Moderiert von user profile iconNarses: Überflüssige Zeilenumbrüche/Leerzeilen entfernt.

_________________
icq 102779206
"God is real, unless declared integer..."
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Mi 28.10.09 23:14 
probiers mal im OnKeyPress. da sollte der Parameter "Key" vom Typ Character sein.

lg elundril

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19336
Erhaltene Danke: 1751

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 29.10.09 00:06 
Oder du musst überall die Asciicodes benutzen, also nicht die Zeichen wie #8 sondern nur die 8 und analog die Zahlenwerte bei den anderen Zeichen.
thepaine91
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 763
Erhaltene Danke: 27

Win XP, Windows 7, (Linux)
D6, D2010, C#, PHP, Java(Android), HTML/Js
BeitragVerfasst: Do 29.10.09 08:25 
ausblenden Delphi-Quelltext
1:
  if not ((Key in [$30..$39]) or (Key = 188 ) or (Key = VK_BACK)) then					


mfg nic
schlumsch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122

alles Win :)
Delphi 2005 Prof, Delphi 2007
BeitragVerfasst: Do 29.10.09 09:58 
Ich danke euch für die Hilfe, probiere ich heute Abend gleich aus aber es klingt zumindest mal nach "gelöst" :)

_________________
icq 102779206
"God is real, unless declared integer..."