Cita:
Empezado por sdiaz1983
...ME PUEDE EXPLICAR EL CODIGO PARA ENTENDERLO, EN PARTICULAR ESTA PARTE.
var Value: Cardinal; Code: Integer;
begin
Val(numero, Value, Code);
if LongBool(Code) then
MIL GRACIAS POR SU AYUDA
|
CLARO QUE SIII
Cita:
Empezado por (F1) sobre la función
Converts a string to a numeric representation.
Delphi syntax:
procedure Val(S; var V; var Code: Integer);
Description
In Delphi code, Val converts the string value S to its numeric representation, as if it were read from a text file with Read.
S is a string-type expression; it must be a sequence of characters that form a signed real number.
V is an integer-type or real-type variable. If V is an integer-type variable, S must form a whole number.
Code is a variable of type Integer.
If the string is invalid, the index of the offending character is stored in Code; otherwise, Code is set to zero. For a null-terminated string, the error position returned in Code is one larger than the actual zero-based index of the character in error.
Val performs range checking differently depending upon the setting of the $R compiler directive and the type of the parameter V.
|
Resumen;
Val intenta convertir
S a un valor numerico. Si lo consigue retorna su valor (entero, real, con signo o no), en la variable
V y retorna en
Code 0 (cero), caso contrario (
S no es reconocida) retorna el error correspondiente en
Code (<> 0)
Saludos