Autor |
Beitrag |
WeBsPaCe
      
Beiträge: 2322
Erhaltene Danke: 1
FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
|
Verfasst: So 09.01.05 19:06
Hi!!!
Folgendes Problem: Ich hab' nen String wie z.B. den da: Ganz toller String: | Ich finde das delphi-forum super!! |
Jetzt will ich, dass dieser String in die einzelnen wörter eingeteilt wird. Also in unserem Beispiel:
wort[1] = Ich
wort[2] = finde
wort[3] = das
wort[4] = delphi-forum
wort[5] = super!!
Danke schon mal, gelle?? 
_________________ Steht der Bauer im Gemüse, hat er später grüne Füße.
|
|
Handycommander
      
Beiträge: 1054
Windows XP Pro, Vista
Visual Studio 2008
|
Verfasst: So 09.01.05 19:10
Hallo,
ich hoffe mal, das hier kann dir helfen!
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
| procedure GetWords(TheString, Separator: String; var Strings: TStringList); begin try Strings.Clear; while Pos(Separator, TheString)>0 do begin Strings.Add(Copy(TheString, 1, Pos(Separator, TheString)-1)); TheString:=Copy(TheString, Pos(Separator, TheString)+Length(Separator), Length(TheString)); end; Strings.Add(TheString); except end; end; |
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8:
| function WordCount(TheString, Separator: String): Integer; var OurStrings: TStringList; begin OurStrings:=TStringList.Create; GetWords(TheString, Separator, OurStrings); result:=OurStrings.count; OurStrings.free; end; |
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
| function GetWord(TheString, Separator: String; Nummer: Integer): String; var OurStrings: TStringList; begin OurStrings:=TStringList.Create; GetWords(TheString, Separator, OurStrings); try result:=OurStrings[Nummer-1]; except result:='' end; OurStrings.free; end; |
MfG
Tobias
Moderiert von Christian S.: Code- durch Delphi-Tags ersetzt.
|
|
tommie-lie
      
Beiträge: 4373
Ubuntu 7.10 "Gutsy Gibbon"
|
Verfasst: So 09.01.05 19:12
_________________ 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
|
|
Sprint
      
Beiträge: 849
|
Verfasst: So 09.01.05 19:22
|
|
tommie-lie
      
Beiträge: 4373
Ubuntu 7.10 "Gutsy Gibbon"
|
Verfasst: So 09.01.05 19:25
Will noch einer? 
_________________ 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
|
|
WeBsPaCe 
      
Beiträge: 2322
Erhaltene Danke: 1
FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
|
Verfasst: Mo 10.01.05 16:02
Hey Jungs, ihr seid super!!! Vielen Dank!!! Alle drei funzen!!! Ich such mir dann mal eins raus... 
_________________ Steht der Bauer im Gemüse, hat er später grüne Füße.
|
|
zangelo
      
Beiträge: 50
|
Verfasst: Mo 10.01.05 21:44
Hi, bin ein delphi anfänger, und mich interessiert nun, wo das jetzt hin muss, also der code, einfach doppelklick auf die form, und dann die 3 codes einfügen?
|
|
|