delphi 判断字符串是否为纯字母组合的函数

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

delphi 判断字符串是否为纯字母组合的函数

  2022-12-25 我要评论

代码一

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

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;

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们