Autor Beitrag
bayou
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 88


D6 PE
BeitragVerfasst: Di 21.06.05 08:43 
Hallo Leute,

Ich hab mir eine Eieruhr (countdown) gebaut und habe dort 3 Edit Felder. 1x für Stund, 1x für Minute und 1x für Sekunde.
In diesen Editfeldern möchte ich immer nur 2 Zahlen erlauben.
Keine Buchstaben und nicht mehr oder weniger als 2 Zahlen.
Ich arbeite noch nicht lange mit Delphi und hab so gut wie keine Erfahrung. Kann mir da jenmand helfen?

Danke
Asgar
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 160

XP Home Edition
D5
BeitragVerfasst: Di 21.06.05 08:58 
du kannst im Object Inspector die eigenschaft maxlength vom edit feld auf 2 setzen, ob es wirklich zahlen sind kannst du ja abfragen

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
var
zahl:String;
a:Integer;

begin

zahl:=edit1.text;                           //Der Variablen zahl wird der text aus dem editfeld zugewiesen.
for a:=1 to length(zahl) do
begin
  if zahl[a] in ['0'..'9'] then             //Die Variable Zahl wird zeichen für zeichen überprüft. 
  else
  showmessage('Nur Zahlen sind erlaubt.');   //wenn der wert keine zahl ist dann wird diese meldung ausgegeben.

end;

end;



Gruß Daniel
bayou Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 88


D6 PE
BeitragVerfasst: Di 21.06.05 12:50 
Super :D , Vielen Dank.