Question: How to Check if a String is numeric?
Answer:
If you mean string is 1,2,3,4 ....0 in string mode.
Here the code:
function IsStrANumber(const S: string): Boolean;
var
P: PChar;
begin
P := PChar(S);
Result := False;
while P^ <> #0 do
begin
if not (P^ in ['0'..'9']) then Exit;
Inc(P);
end;
Result := True;
end;
Subscribe to:
Post Comments (Atom)






I have heard about another way of cheap sql database repair. Besides, you can visit my blogs at: http://daspeac.livejournal.com/ or http://daspeac.blogspot.com/ where I’m trying to share my experience with regard to data corruption issues.
or this one
function IsStrANumber(const S: string): Boolean;
begin
Result := True;
try
StrToInt(S);
except
Result := False;
end;
end;
Nice one ..thanks for sharing trick questions about Delphi development.