Answers for "delphi check if string contains only numbers"

0

how to check if something is only numbers in delphi

if TryStrToInt(Edit1.Text, Value) then
  DoSomethingWithTheNumber(Value)
else
  HandleNotANumberError(Edit1.Text);
Posted by: Guest on March-08-2020
0

how to validate if the text in edit has numbers in and to show a message if it has in delphi

// Taking OP question obsessively literally, this 
// function doesn't allow negative sign, decimals, or anything
// but digits
function IsValidEntry(s:String):Boolean;
var
  n:Integer;
begin
  result := true;
  for n := 1 to Length(s) do begin
    if (s[n] < '0') or (s[n] > '9') then
    begin
       result := false;
       exit;
    end;
  end;
end;
Posted by: Guest on September-21-2020

Code answers related to "delphi check if string contains only numbers"

Browse Popular Code Answers by Language