Fórum Contador de caracteres #198401
02/12/2003
0
Título editado pelo Moderador - AZ
Crcam
Curtir tópico
+ 0Posts
03/01/2004
Fabiosilva
Insira o codigo no evento onchange
var
I: Integer;
Ch: Char;
Cnttotal: Integer;
begin
Cnttotal := 0;
for I := 1 to Length(Memo1.Text) do
begin
Ch := Memo1.Text[I];
if Ch in ChrMaiusculas then
Inc(Cnttotal);
else
if Ch in ChrMinusculas then
Inc(Cnttotal);
else
if Ch in ChrNumeros then
Inc(Cnttotal);
else
if Ch in ChrBrancos then
Inc(Cnttotal);
else
if Ch in ChrEspeciais then
Inc(Cnttotal);
else
Inc(Cnttotal);
LblDigitos.Caption := IntToStr(Cnttotal);
Gostei + 0
03/01/2004
Fabiosilva
Insira o codigo no evento onchange
var
I: Integer;
Ch: Char;
Cnttotal: Integer;
begin
Cnttotal := 0;
for I := 1 to Length(Memo1.Text) do
begin
Ch := Memo1.Text[I];
if Ch in ChrMaiusculas then
Inc(Cnttotal);
else
if Ch in ChrMinusculas then
Inc(Cnttotal);
else
if Ch in ChrNumeros then
Inc(Cnttotal);
else
if Ch in ChrBrancos then
Inc(Cnttotal);
else
if Ch in ChrEspeciais then
Inc(Cnttotal);
else
Inc(Cnttotal);
LblDigitos.Caption := IntToStr(Cnttotal);
Gostei + 0
03/01/2004
Deus
for i := 1 to Length(Memo1.Text) do begin Ch := Memo1.Text[i]; if (Ch in ChrMaiusculas) or (Ch in ChrMinusculas) or (Ch in ChrNumeros) or (Ch in ChrBrancos) or (Ch in ChrEspeciais) then Inc(Cnttotal); end; LblDigitos.Caption := IntToStr(Cnttotal);
Sem falar que eu não entendi o porquê de tantos sets. Não seria melhor um set só, assim:
for i := 1 to Length(Memo1.Text) do begin if (Memo1.Text[i] in [´a´..´Z´, ´0´..´9´, ´ ´]) then Inc(Cnttotal); end; LblDigitos.Caption := IntToStr(Cnttotal);
Acho que seria melhor. Ele queria para um Memo, ou para um DBEdit? É só mudar o nome do controle, então. Desta forma, você não vai precisar declarar tantas variáveis - só [i:53dc7f32ec]i[/i:53dc7f32ec], que vai servir para a contagem.
Abraços, dEUS.
Gostei + 0
03/01/2004
Demian Soares
label1.caption := inttostr(length(DBEdit1.Text));
pronto enquanto vc estiver digitando ou apagndo ele ira incrementar ou decrementr...so...
Gostei + 0
03/01/2004
Cebikyn
Gostei + 0
03/01/2004
Cebikyn
No caso do DBEdit é válido o uso de Length.
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)