Autor Beitrag
Thunder
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 145

WinXP
D6 Pers
BeitragVerfasst: Di 26.11.02 19:30 
Hallo,

Ich möchte, das Edit1.Text geprüft wird, das es ein HEX-Wert ist und dann an einer Stelle die entsprechende Farbe aus dem 6stelligem HEX-Wert angezeigt wird...

Wie??

Danke im Voraus

Oder kennt einer ne passende Komponente??
Visum
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 106



BeitragVerfasst: Di 26.11.02 21:33 
Hi,
die Überprüfung könntest du ganz einfach mit einer langen IF - Anweisung machen:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
if (edit1.text[1]='$') and 
  (edit1.text[2] in ['0'..'9','A','B','C','D','E','F','a','b','c','d','e','f']) and
  (edit1.text[3] in ['0'..'9','A','B','C','D','E','F','a','b','c','d','e','f']) and 
  ... //für alle 7 Buchstaben 

  then ... else

Das könnte man durch eine For - Schleife evtl. erleichtern.

Die Umwandlung in eine Farbe geht mit StringToColor, z.B.:
ausblenden Quelltext
1:
form1.color:= StringToColor(edit1.text);					


mfG
Visum
MathiasH
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 699

WinXP, Win98SE, Debian, Win95
D5 Stand, D6 Prof
BeitragVerfasst: Mi 27.11.02 14:14 
einfacher :P : bette das stringtocolor in einen try-except Block ein!
wenn er konvertieren kann geht es ganz normal weiter, ansonsten wird abgebrochen

MathiasH

_________________
"Viel von sich reden, kann auch ein Mittel sein, sich zu verbergen."
Friedrich Nietzsche
Visum
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 106



BeitragVerfasst: Mi 27.11.02 17:14 
Ja, geht auch ;) , nervt aber in der Entwicklungsumgebung ...
darüber wird aber schon wo anders diskutiert :P