Delphi判断字符串是否是数字、字母、大小写字母

function IsNumberic(Vaule:String):Boolean;   //判断Vaule是不是数字
var
i:integer;
begin
result:=true;   //设置返回值为 是(真)
Vaule:=trim(Vaule);  //去空格
  for i:=1 to length(Vaule) do  //准备循环
    begin
      if not (Vaule[i] in ['0'..'9']) then  //如果Vaule的第i个字不是0-9中的任一个
        begin
          result:=false;  //返回值 不是(假)
          exit;  //退出函数
        end;
    end;
end;

function IsUpperCase(Vaule:String):Boolean;   //判断Vaule 是不是大写字母
var
i:integer;
begin
result:=true;  //设置返回值为 是
Vaule:=trim(Vaule);   //去空格
  for i:=1 to length(Vaule) do   //准备循环
    begin
      if not (Vaule[i] in ['A'..'Z']) then  //如果Vaule的第i个字不是A-Z中的任一个
        begin
          result:=false;  //返回值 不是
          exit;  //退出函数
        end;
    end;
end;

function IsLowerCase(Vaule:String):Boolean;  //判断Vaule 是不是小写字母
var
i:integer;
begin 
result:=true;   //设置返回值为 是
Vaule:=trim(Vaule);   //去空格
  for i:=1 to length(Vaule) do   //准备循环
    begin
      if not (Vaule[i] in ['a'..'z']) then   //如果Vaule的第i个字不是a-z中的任一个
        begin
          result:=false;   //返回值 不是
          exit;   //退出函数
        end;
    end;
end;

同理 如果想判断是不是字母的话

function IsEnCase(Vaule:String):boolean;    //判断Vaule 是不是字母
var
i:integer;
begin 
result:=true;   //设置返回值为 是
Vaule:=trim(Vaule);   //去空格
  for i:=1 to length(Vaule) do   //准备循环
    begin
      if (not (Vaule[i] in ['A'..'Z'])) or
         (not (Vaule[i] in ['a'..'z'])) then   //如果Vaule的第i个字不是A-Z或者a-z中的任一个
        begin
          result:=false;   //返回值 不是
          exit;   //退出函数
        end;
    end;
end;

 

posted on 2013-07-12 13:00  哈哈哈哈BBA  阅读(9106)  评论(1编辑  收藏  举报

导航