Autor Beitrag
Ice
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114



BeitragVerfasst: Fr 24.01.03 13:52 
Hallo Leute,

ich habe folgendes Problem: Ich möchte die Eingabe in ein EditField auf Zahlen checken, werden Zahlen eingegeben ist das OK, wenn nicht sollte ein Fehler kommen.
Hat da jemand ne Idee oder nen Hinweis?

Im voraus schon mal vielen Dank,

Ice
opfer.der.genauigkeit
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754
Erhaltene Danke: 1



BeitragVerfasst: Fr 24.01.03 14:02 
Schau mal in der Komponentenliste unter Zusätzlich, da gibt´s MaskEdit. Ist denk ich mal die einfachste Variante. Ansonsten mußt du die Eingabetasten abfragen. Oder du durchsuchst den String im Edtfeld nach deinen Kriterien.

Und zum Erzeugen der Fehlermeldung: ShowMessage() oder MessageDlg(); Je nachdem was du dann machen magst.

_________________
Stellen Sie sich bitte Zirkusmusik vor.
Ice Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114



BeitragVerfasst: Fr 24.01.03 14:52 
sorry mit MaskEdit funktioniert das nicht ich müsste schon eien Abfrage programmieren, aber trotzdem danke!

Wie kann ich denn das word format z.b. in einen Charakter umwandeln?Dann könnte ich nämlich in einem set nach dem Character suchen und wenn er nicht dabei ist einen Error auslösen...

Ice
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: Fr 24.01.03 14:56 
Hallo,

schau Dir einmal das Ereignis OnKeyPress des Edit-Feldes an. Das ist Dein Einstiegspunkt. Dort kannst Du dann das in Key übergebene Zeichen prüfen, ob es eine Zahl ist.

In etwa so:
ausblenden Quelltext
1:
2:
3:
4:
TForm1.Edit1KeyPress(Sender:TObject; var Key:Char);
begin
  if not (Key in ['0'..'9', #8]) then Key:=#0;
end;

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
Ice Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114



BeitragVerfasst: Fr 24.01.03 15:09 
Alles klar, vielen dank!!
opfer.der.genauigkeit
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754
Erhaltene Danke: 1



BeitragVerfasst: Fr 24.01.03 16:01 
smiegel hat folgendes geschrieben:


In etwa so:
ausblenden Quelltext
1:
2:
3:
4:
TForm1.Edit1KeyPress(Sender:TObject; var Key:Char);
begin
  if not (Key in ['0'..'9', #8]) then Key:=#0;
end;


*An Stirn langt*
Es geht manchmal so einfach und ich denk nich dran. :autsch:

_________________
Stellen Sie sich bitte Zirkusmusik vor.
hansg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 168

Win XP Professional SP3, Vista Ultimate 32 SP1
Delphi 6 Professional
BeitragVerfasst: Fr 24.01.03 21:22 
Hallo,
schau mal hier www.delphi-forum.de/viewtopic.php?t=6261 ich hatte ein ähnliches Problem.
Wobei Du
ausblenden Quelltext
1:
 s:='TextmitZahlen012336undSonderzeichen#$%';					

durch
 s:=edit1.text; ersetzt.

Gruß Hans
Ice Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 114



BeitragVerfasst: Di 28.01.03 12:01 
Alles klar . vielen Dank!!!!
:D

Ice
foxy
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 814

Ubuntu, Gentoo
C++, PHP, Java, Ruby, Perl (Eclipse)
BeitragVerfasst: Di 28.01.03 12:13 
kannst auch arbeiten mit array
ausblenden Quelltext
1:
k := array [32..255] of byte					

geht auc so prüfste ob irgendwas drin steht

_________________
"Only wimps use tape backup: real men just upload their important stuff on ftp, and let the rest of the world mirror it." (Linus Torvalds)
OperatingSystem Laptop (Ubuntu Hardy)