Delphi function to check a string if it's number


function IsNumber(Text: String): Boolean;
var i: Integer;
    c: char;
begin
  Result := True;
  if Length(Text) <= 0 then
    Result := False;
  for i := 1 to Length(Text) do
  begin
    c := Text[i];
    if not ((c >= '0') and (c <= '9')) then
    if not ((c = DecimalSeparator) and (i > 1)) then
    if not ((c = '-') and (i = 1)) then
    if not ((c = '+') and (i = 1)) then
    begin
      Result := False;
      //Break;
    end;
  end;
end;

1 comment: