Delphi-PRAXiS
Seite 3 von 3     123   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Abfragen (https://www.delphipraxis.net/49741-abfragen.html)

Catbytes 15. Jul 2005 11:55

Re: Abfragen
 
Zitat:

Zitat von r2c2
2.) nicht Zahl-Zeichen abfangen(turboPASCAL) Das würde ich dann aber noch etwas verbessern:
Delphi-Quellcode:
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  ...
  if not (Key in ['0'..'9', '.', ',', #8 ]) then
  begin
    Beep;
    Key := #0;
  end;
  ...
end;

"Key" ist vom Typ "Word". Richtigerweise moniert Delphi dann:
"[Fehler] Unit1.pas(30): Inkompatible Typen: 'Word' und 'Char'"

r2c2 15. Jul 2005 11:59

Re: Abfragen
 
Zitat:

Zitat von Catbytes
"Key" ist vom Typ "Word". Richtigerweise moniert Delphi dann:
"[Fehler] Unit1.pas(30): Inkompatible Typen: 'Word' und 'Char'"

Das kommt davon, wenn man zu viel Copy&Paste benutzt! :mrgreen:

Das ganze mit OnKeyPress und es funktioniert!

mfg

Christian

Catbytes 15. Jul 2005 12:03

Re: Abfragen
 
Zitat:

Zitat von r2c2
Das ganze mit OnKeyPress und es funktioniert!

Soweit so gut - aber wenn ich mit Copy&Paste (wo wir schon beim Thema sind :mrgreen:) was einfüge, klappt es auch nicht.

Das "kleine" Problem ist komplexer als erwartet...

Edit: Vielleicht hilft auch das weiter.

r2c2 15. Jul 2005 13:49

Re: Abfragen
 
Zitat:

Zitat von Catbytes
Zitat:

Zitat von r2c2
Das ganze mit OnKeyPress und es funktioniert!

Soweit so gut - aber wenn ich mit Copy&Paste (wo wir schon beim Thema sind :mrgreen:) was einfüge, klappt es auch nicht.

Das "kleine" Problem ist komplexer als erwartet...

Edit: Vielleicht hilft auch das weiter.

Jo, is mir klar, das mit dem Copy&Paste. Wr das verhindern will nimmt entweder Möglichkeit Nr. 3,folgt deinem Link oder bastelt sich selbst was(Das wäre Nr. 4). Bei letzterem muss man Nr. 2 so erweitern, dass falsche Punkte/Kommas, etc. auch abgefangen werden und zusätzlich muss man Copy&Paste(per OnChange) noch abfragen und ggf. alles rausnehmen, was da nicht hingehört.

mfg

Christian


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:16 Uhr.
Seite 3 von 3     123   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz