现在正在做一个人员管理系统,里面需要这个东东,但是现在只有一个PB7写的DLL提供了这个函数,但是需要pb的DLL太多了,主管很不满意,所以各位快帮帮忙啊,如果今天就能给我,再开100分表示感谢

解决方案 »

  1.   

    function TForm1.f(ID: string):string;
    const
      W:array [1..18] of integer = (7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1);
      A:array [0..10] of char = ('1','0','x','9','8','7','6','5','4','3','2');
    var
      i, j, S: integer;
      NewID: string;
    begin
      if Length(ID) <> 15 then
        result:= ''
      else begin
        NewID:= ID;
        Insert('19', NewID, 7);
        S:= 0;
        try
          for i:=1 to 17 do begin
            j:= StrToInt(NewID[i]) * W[i];
            S:= S + j;
          end;
        except
          result:= '';
          exit;
        end;
        S:= S mod 11;
        Result:= NewID + A[S];
      end;
    end;
    copy过来的18-15
      

  2.   

    //15位转18位函数
    function TForm1.ID15To18(OldID:string):string ;
    var
      i:Integer;
      num:Integer;
      code:string;
      strtemp:string;
      pvalue:string;
    begin
      num:=0;
      strtemp:=Leftstr(OldID,6)+ '19'+Rightstr(OldID,9);
      for i:=18 downto 2 do
        begin
          pvalue:=floattostr(power(2,i-1));
          num:=num +(strtoint(pvalue) mod 11) * strtoint(Midstr(strtemp, 19 - i, 1));
        end;
      num:=num mod 11;
      case num of
        0: code:='1';
        1: code:='0';
        2: code:='X';
        else
          code:=inttostr(12-num);
      end;
      Result:=strtemp+code;
    end;肯定好用的函数