Criar funções isFloat e isInteger sem usar Exception

Apreenda a criar duas funções para validar se determinado valor é inteiro ou float, sem usar bloco try except.

function IsInteger(value:variant):Boolean;
  var
     temp, errorPos :integer;
  begin
      Val(Value, temp, errorPos);
      if errorPos = 0 then
         result :=(temp-round(temp))=0;
 end;
 
 
 function IsFloat(value:variant):Boolean;
  var
     temp, errorPos :integer;
  begin
      Val(Value, temp, errorPos);
      result := (errorPos = 0);   
  end;
Ebook exclusivo
Dê um upgrade no início da sua jornada. Crie sua conta grátis e baixe o e-book

Artigos relacionados