Topic: count characters

Hello MVD users

I want to count the number of characters in a memo. For every 160 characters = 1sms and when greater than 160 characters but less than 320 characters = 2sms and so on. Thank you in advance for your assistance.

Re: count characters

procedure Form1_Memo1_OnChange (Sender: TObject);
begin
  Form1.Label1.Caption :=
  Format('Total: %d sms (%d characters)',
  [(length(Form1.Memo1.Text)-1) div 160 + 1,
   length(Form1.Memo1.Text)]);
end;

begin
 Form1_Memo1_OnChange(nil);
end.

Re: count characters

vovka3003 wrote:
procedure Form1_Memo1_OnChange (Sender: TObject);
begin
  Form1.Label1.Caption :=
  Format('Total: %d sms (%d characters)',
  [(length(Form1.Memo1.Text)-1) div 160 + 1,
   length(Form1.Memo1.Text)]);
end;

begin
 Form1_Memo1_OnChange(nil);
end.

Excellent!!! It works like magic. Thank you very much