Re: Find character among the digits values


[ DelphiLand Discussion Forum ]

Posted by webmaster Guido on March 25, 19103 at 02:05:09:

In Reply to: Find character among the digits values posted by sam sgling07 on March 23, 19103 at 21:58:11:

: Can someone help me to find the answer.
: I have declared a variable, it has both string and
: integer values inside. e.g. d:='1234dfg345'.
: The question is how to get the string value among the integer values. OR how do I know there are some characters inside the variable.
: Thanks for help.
---------

You can use the Delphi procedure VAL to write a function that returns TRUE or FALSE depending on the fact if a string S contains only numerical characters or not, in other words: if it holds a valid integer number:

Function ValidIntegerString(S: string): Boolean;
var
I, Code: Integer;
begin
Val(S, I, Code);
Result := Code = 0;
end;

You can look up VAL in the Delphi help to find out exactly what it does.


Related Articles and Replies:


[ DelphiLand Discussion Forum ]