Could not Convert variant of type (Olestr) into type (Double)

Asked

Viewed 511 times

0

I want to do a loop loop where every loop it arrow the person’s name plus the variable, but when I join the integer type variable with an error message text saying "Could not Convert Variant of type (Olestr) into type (Double).

Someone’s been through it and can give me a light.

procedure CadastrarPessoa;
var
Contador, n1: integer;

begin
n1:= 1;

for Contador:= 0 to 9 do  
begin
CadastraPessoa.AbrirCadastraPessoa;

CadastraPessoa.BtnNovo;
CadastraPessoa.InformaNome('Morador Modelo ' + n1);
CadastraPessoa.CheckEnderecoCondominio;
CadastraPessoa.InformaTelefone('(37) 3222-2244');
CadastraPessoa.InformaCelular('(37) 98877-6699');
CadastraPessoa.InformarEmail('morador' + n1 + '@teste.com');
CadastraPessoa.FinalizaCadastro;

CadastraPessoa.BtnGravar;
CadastraPessoa.BtnSair;
n1:= n1 + 1;
end;
end;

If I set only one string works or if I set only one number it works also now when I put these two together from the error.

2 answers

2


Convert Integer to Text that will work:

CadastraPessoa.InformarEmail('morador' + IntToStr(n1) + '@teste.com');

In Delphi to concatenate a String with another type it is necessary to perform conversions, for example:

ValorTotal: Double -> 'Valor:'+ FloatToStr(ValorTotal);
Quantidade: Integer -> 'Tem '+ IntToStr(Quantidade) +' de maças na cesta';
  • Thanks, it worked out here I can’t believe this was my mistake.

  • 1

    For nothing, just be sure to mark some of the answers as "Accept"!

1

You are trying to concatenate a String with an integer. Conversion is required 'Your String ' + Inttostr(n1);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.