function CountWords(Text: String): Integer;
type
TExplodedString = array of String;
function Explode(Text: String; Seperator: Char): TExplodedString;
var
I: Integer;
Tmp: String;
begin
if Text[Length(Text)] <> Seperator then
Text := Text + Seperator;
for I := 1 to Length(Text) do begin
if Text[I] = Seperator then begin
SetLength(Result, High(Result)+2);
Result[High(Result)] := Tmp;
Tmp := '';
end else
Tmp := Tmp + Text[I];
end;
end;
var
Tmp: TExplodedString;
begin
Tmp := Explode(Text, ' ');
ShowMessage(IntToStr(Length(Tmp)));
end;
Den kaldes så med:
CountWords(DinRichEdit.Text);
MH.
The-Freak
Livet er for kort til at kede sig.