User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 391,548 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,566 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser:
Views: 7628 | Replies: 2 | Solved
Reply
Join Date: Jan 2006
Posts: 16
Reputation: Katrix36 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Katrix36 Katrix36 is offline Offline
Newbie Poster

Character/letter count

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2006
Posts: 219
Reputation: Lord Soth is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
Lord Soth's Avatar
Lord Soth Lord Soth is offline Offline
Posting Whiz in Training

Solution Re: Character/letter count

  #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  
Join Date: Apr 2006
Posts: 5
Reputation: daycartes is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
daycartes daycartes is offline Offline
Newbie Poster

Re: Character/letter count

  #3  
Apr 24th, 2006
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;]
Last edited by cscgal : May 9th, 2006 at 10:11 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Pascal and Delphi Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Pascal and Delphi Forum

All times are GMT -4. The time now is 9:08 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC