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;

12 Responses so far.

  1. daspeac says:

    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.

  2. Anonymous says:

    or this one

    function IsStrANumber(const S: string): Boolean;
    begin
    Result := True;
    try
    StrToInt(S);
    except
    Result := False;
    end;
    end;

  3. Nelson says:

    Nice one ..thanks for sharing trick questions about Delphi development.

  4. tester says:
    This comment has been removed by the author.
  5. tester says:

    i meant lop678jui

  6. tester says:

    if you enter fre890dom it excepts even if you
    codes
    if not (P^ in ['0'..'9']) then Exit;
    or
    if (P^ in ['a'..'Z']) then Exit;

  7. Anonymous says:

    Hellо therе, I found your website vіa Google аt the samе tіme
    аѕ lookіng foг a rеlated topіc, your site got here up, it aрρears tо bе like good.
    I have boοkmaгkеd it in my google bookmarks.

    Ηеllo there, just became awarе of youг weblog vіa Google,
    and found that it's truly informative. I'm going tο be саreful foг brussеlѕ.

    I'll be grateful if you continue this in future. A lot of folks shall be benefited out of your writing. Cheers!

    Here is my blog; cheap party pills

Post a Comment

Thank you for your comment.

Any request and idea are welcome.

CLICK TO REGISTER