Hello new to this site - looking for help counting specific characters from a single word input by a text box,

Thanks
Wes

Recommended Answers

All 6 Replies

probably length. what you're using? editbox,memo,etc?

Hi,
I am new to delphi and I have a delphi designed dos point of sale program.
I need assistance to open the program for a small reward.
If you are interested I can mail you the executables and further instructions.

i am using an edit box with a single word,

procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(inttostr(length(trim(edit1.Text))));
end;

thank you but this gives the total length of the text - if 'barbara' is entered and the character is 'a' - the result must be 3

your help appreciated

thank you but this gives the total length of the text - if 'barbara' is entered and the character is 'a' - the result must be 3

your help appreciated

this is very simple, i'll give you the answer but i'm not sure how much you'll learn.

counter:=0;
for i:=1 to length(s) do
if s=your_character then
inc(counter)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.