Contando letras e linhas no Memo.

Delphi

30/09/2003

QUAL SERIA O CODIGO PARA MOSTRAR NUM LABEL O NUMERO DE LETARS Q ESCREVO OU APAGO NUM MEMO? NO MESMO CODIGO CONTASSE O NUMERO TOTAL DE LINHAS..

AGRADEÇO

NELSON :o

[i:8f134c5131]Título em maiúsculas editado. Procure digitar também as mensagens em minúsculas. Leia as [url=http://delphiforum.icft.com.br/forum/viewtopic.php?t=6689][u:8f134c5131]Regras de Conduta[/u:8f134c5131][/url]. (marcelo.c - Moderador)[/i:8f134c5131]


Njunior

Njunior

Curtidas 0

Melhor post

Dhiogo

Dhiogo

30/09/2003

Label1.Caption:= Memo1.Lines.Count; {Linhas do memo}
Label2.Caption:=inttostr(Length(memo1.Lines.text)); {Numero de Letras}


GOSTEI 1

Mais Respostas

Ljr

Ljr

30/09/2003

Contar as linhas é fácil

Label1.Caption:= Memo1.Lines.Count;



GOSTEI 0
Ljr

Ljr

30/09/2003

Complementando a resposta de nosso cologa, coloquei o que ele nos sugeriu no evento Change do Memo e ficou beleza.

procedure TForm1.Memo1Change(Sender: TObject);
begin
  Label1.Caption:= IntToStr(Memo1.Lines.Count);
  Label2.Caption:= IntToStr(length(Memo1.Lines.Text));
end;



GOSTEI 0
Cebikyn

Cebikyn

30/09/2003

Complementando as duas respostas anteriores:

O código [b:b4cac3e3f7]length(Memo1.Lines.Text)[/b:b4cac3e3f7] conta cada mudança de linha como sendo um caractere, para evitar isso, deve-se usar:
[b:b4cac3e3f7]length(Trim(Memo1.Lines.Text))[/b:b4cac3e3f7]


GOSTEI 0
POSTAR