943,851 Members | Top Members by Rank

Ad:
Mar 3rd, 2006
0

Character/letter count

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Katrix36 is offline Offline
16 posts
since Jan 2006
Mar 17th, 2006
0

Re: Character/letter count

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
Reputation Points: 28
Solved Threads: 4
Posting Whiz in Training
Lord Soth is offline Offline
233 posts
since Mar 2006
Apr 24th, 2006
0

Re: Character/letter count

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
daycartes is offline Offline
5 posts
since Apr 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: Sending keystrokes to MS Word
Next Thread in Pascal and Delphi Forum Timeline: change system date





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC