for j := 1 to Seriallength do      
    begin
      if  Serialtype = 10 then
      begin
        CheckStr := UpperCase(Copy(barcode,j,1));
        if  not (CheckStr[1] in ['0','1','2','3','4','5','6','7','8','9']) then
          Result := false
        else
          Result := true;
      end

解决方案 »

  1.   

    前面的循环判断就不说了
    CheckStr := UpperCase(Copy(barcode,j,1));
    这句是把barcode从j开始1个字符转大写赋给CheckStrCheckStr[1] in是判断CheckStr第一个字符是否在['0','1','2','3','4','5','6','7','8','9']范围内
      

  2.   

    晕倒,这段代码怎么写成这样啊,本来可以很简单的,写的这么复杂,哎.....
    for j := 1 to Seriallength do   
      begin
      if Serialtype = 10 then
      begin
      CheckStr := UpperCase(Copy(barcode,j,1));//取barcode的第j个字符
      //如果CheckStr的第一个字符(实际上这个字符串就一个字符),不是0到9(不是数字)就返回值为false,否则返回值为true
      if not (CheckStr[1] in ['0','1','2','3','4','5','6','7','8','9']) then
      Result := false
      else
      Result := true;
      end
    这段代码的意思就是:扫描barcode这个字符串,
    如果Serialtype不是10,继续循环,
    如果是10,进行下列判断:
    详见上面注释,这段代码的结果就是:
    如果Serialtype不是10,继续循环,
    如果是10
    如果barcode[Seriallength]是数字就返回true不是就返回false
    代码可简化为:
      if Serialtype = 10 then
        result :=barcode[Seriallength] in ['0','1','2','3','4','5','6','7','8','9'];