Character/letter count

Thread Solved

Join Date: Jan 2006
Posts: 16
Reputation: Katrix36 is an unknown quantity at this point 
Solved Threads: 0
Katrix36 Katrix36 is offline Offline
Newbie Poster

Character/letter count

 
0
  #1
Mar 3rd, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 233
Reputation: Lord Soth is an unknown quantity at this point 
Solved Threads: 4
Lord Soth's Avatar
Lord Soth Lord Soth is offline Offline
Posting Whiz in Training

Re: Character/letter count

 
0
  #2
Mar 17th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5
Reputation: daycartes is an unknown quantity at this point 
Solved Threads: 0
daycartes daycartes is offline Offline
Newbie Poster

Re: Character/letter count

 
0
  #3
Apr 24th, 2006
try the following, to count the number of letters in a particular line(0)

Pascal and Delphi Syntax (Toggle Plain Text)
  1. [procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3. a:Integer;
  4. begin
  5. a:=length(Memo1.Lines[0]);
  6. label1.Caption:=IntToStr(a);
  7. end;]
  8.  
  9. or to count the number of total letters (in fact characters)
  10. [procedure TForm1.Button1Click(Sender: TObject);
  11. var
  12. a,b,c:Integer;
  13. begin
  14. a:=length(Memo1.Lines[0]);
  15. label1.Caption:= IntToStr(length(Memo1.Lines.Text)) ;
  16. end;]
Last edited by cscgal; May 9th, 2006 at 11:11 pm.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC