天天看點

判斷,字元為漢字,數字

function IsNumber(const s: string): Boolean;

var

  i: Integer;

begin

  if IsEmpty(s) or not (Pos('-', s) in[0, 1]) then

  begin

    Result := False;

    Exit;

  end;

  Result := True;

  for i := 1 to Length(s) do //Not empty:

    if not (s[i] in ['0'..'9', '.', '-']) then

    begin

      Result := False;

      Break;

    end;

end;

function IsAlpha(const s: string): Boolean;

  Result := False;

  for i := 1 to Length(s) do

    if s[i] in ['A'..'Z', 'a'..'z'] then

      Result := True;

function IsAllAlpha(const s: string): Boolean;

    if not (s[i] in ['A'..'Z', 'a'..'z']) then

繼續閱讀