0

Hey all,

Would anyone be able to help me out with some code to count how many characters there are in a string e.g.

A label disaplys the number of characters that the user has typed into a memo.

Katrix36

3
Contributors
2
Replies
6
Views
11 Years
Discussion Span
Last Post by daycartes
0

Hi,

If you count the white spaces and CRs and LFs as character too, you can simply use Edit1.Text := IntToStr(Len(Memo1.Text)); to show the number of chars on Edit1 and if you put the above code on Memo1's OnChange then it will show the char count at real time as the user writes.

Loren Soth

0

try the following, to count the number of letters in a particular line(0)

[procedure TForm1.Button1Click(Sender: TObject);
var
a:Integer;
begin
a:=length(Memo1.Lines[0]);
label1.Caption:=IntToStr(a);
end;]
 
or to count the number of total letters (in fact characters)
[procedure TForm1.Button1Click(Sender: TObject);
var
a,b,c:Integer;
begin
a:=length(Memo1.Lines[0]);
label1.Caption:= IntToStr(length(Memo1.Lines.Text)) ;
end;]
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.