Autor Beitrag
lonley-lovley
Hält's aus hier
Beiträge: 8



BeitragVerfasst: So 11.12.05 22:51 
hab ein problem kann ich aufzählung in einer einfachauswahl realisieren?
und wenn ja wie
beispiel untenstehend

ausblenden Delphi-Quelltext
1:
2:
3:
4:
if edbildgang.text ='OB'
   then
   if alles <> '6'     <- brauche hier ein 6 bis 9
   then libanzeige.items.Delete(i);

thx

Moderiert von user profile iconTino: Delphi-Tags hinzugefügt.
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: So 11.12.05 22:56 
Von welchem Typ ist "alles"? Wenn es vom Typ Char ist, kannst du dir den Operator in mal anschauen und ein Set ['6'..'9'] bilden.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
lonley-lovley Threadstarter
Hält's aus hier
Beiträge: 8



BeitragVerfasst: So 11.12.05 23:03 
Titel: mh
nein alles ist ein string...

der dann zwar nur noch aus einem zeichen besteht weil alles andere gelöscht ist wie wandle ich den einen string in character um??? vielleicht geht das ja
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: So 11.12.05 23:17 
Hallo,

wenn der String nur ein Zeichen hat kannst Du es direkt einem Char zuweisen.

Aber bezugnehmend auf den anderen Thread geht es auch direkt so:
ausblenden Delphi-Quelltext
1:
 if alles[z+2] in ['6'..'9'] then					

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Mo 12.12.05 12:55 
user profile iconLannes hat folgendes geschrieben:
wenn der String nur ein Zeichen hat kannst Du es direkt einem Char zuweisen.
Echt? Seit wann denn das? :shock:

Strings kann man prinzipiell wie ein Array inidizieren und man erhält einen Char. Ist s ein String mit 5 Zeichen, ergibt s[2] das zweite Zeichen des Strings (bei 1 beginnend zu zählen), das du mit dem Operator in wie oben beschrieben überprüfen kannst.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 12.12.05 13:10 
Hallo,

stimmt, falsch ausgedrückt :oops:
Besser: "Ein einzelnes Zeichen eines Strings kann man direkt zuweisen"
Beispiel:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
var     c : Char;
    alles : String;
//...
  c := alles[1];

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )