Ver Mensaje Individual
  #3  
Antiguo 05-02-2007
Avatar de ixMike
ixMike ixMike is offline
Miembro
 
Registrado: feb 2004
Posts: 1.151
Reputación: 22
ixMike Va por buen camino
Sí, claro que se puede:

Código Delphi [-]
 
If IsFloat(Edit1.text) then [...]
If IsInteger(Edit1.text) then [...]

pero necesitarás esto:

Código Delphi [-]
 
function IsFloat(s: string): boolean;
var n: double;
begin
try
 n:=StrToFloat(s);
 result:=True;
 except
 result:=False;
 end;
end;
 
function IsInteger(s: string): boolean;
var n: integer;
begin
try
 n:=StrToInt(s);
 result:=True;
 except
 result:=False;
 end;
end;

Lo que hace cada función es convertir el contenido del Edit.Text a una variable numérica del correspondiente tipo. Si todo va bien, pues es válido, sino, pues da error.

Espero que te sirva de ayuda.

Saludos.

PD: las funciones se me acaban de ocurrir, no sé si Delphi ya tiene alguna por el estilo implementada.
Responder Con Cita