Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Richedit iteration

Status
Not open for further replies.

cyberant

Programmer
Sep 21, 2003
44
ZA
Hey everyone

I'm needing to iterate through a richedit components text character by character but I only seem to be able to edit it 1 line at a time.

What is the command for this? I would have assumed it was something like richedit1.lines?

Thanks
 
Hi Cyberant,

the Lines property will give you one line at time, use the text property if you want all lines in one big string...

--------------------------------------
What You See Is What You Get
 
I know, but how do I now iterate through the text one character at a time?
 
euh,

var s : string;

....
s:=richedit1.text;
for i:=1 to length(s) do
begin
...
if s=' ' then inc(spacecount); // character = s
...
end

--------------------------------------
What You See Is What You Get
 
How do I now iterate through richedit.text one character at a time?
 
euh, that's what the code above is doing!

Code:
var 
//declare a string
s : string;
i : integer;

....
//set the text in the RichEdit to the variable
s:=richedit1.text;
//from the 1 character in the string to the last character in the string do something
for i:=1 to length(s) do
begin
...
if s[i]=' ' then inc(spacecount); // character = s[i]
...
end



Leslie
 
Sorry! I hadn't seen you previous post, I must be blind. I actually ended up doing it that way before I saw the post, just thought that perhaps there was an easier way handling it directly with the component.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top