DELPHI的帮助: /************* 要USE IdGlobal 单元 Determines if a character is a numeric digit. function IsNumeric(c: char): Boolean;Parametersc: charCharacter to be examined. ReturnsBoolean - True if the character is a numeric digit. DescriptionIsNumeric is a Boolean function that indicates if the character in c contains a numeric digit in the range '0'..'9'.
判断单个字符是否是数字型的字符
if IsNumeric('4') then showmessage('Yes') else showmessage('No');
var I: Integer; begin if TryStrToInt('123', I) then { TODO } end;
/*************
要USE IdGlobal 单元
Determines if a character is a numeric digit.
function IsNumeric(c: char): Boolean;Parametersc: charCharacter to be examined.
ReturnsBoolean - True if the character is a numeric digit.
DescriptionIsNumeric is a Boolean function that indicates if the character in c contains a numeric digit in the range '0'..'9'.
if IsNumeric('4') then
showmessage('Yes')
else
showmessage('No');
I: Integer;
begin
if TryStrToInt('123', I) then
{ TODO }
end;
public static boolean isNumeric(String s)
{
if((s != null)&&(s!=""))
return s.matches("^[0-9]*$");
else
return false;
}
public static boolean isFloat(String s){
if((s != null) && !s.equals(""))
return s.matches("^[0-9]+[\\.]?[0-9]*$");
else
return false;
}