干吗用字符串(还需转换为整数),直接用整数就可以了:
function TForm1.IDToNewID(ID: String): String; const iPosPower : array[1..17] of integer = (7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2); var i,SfzXy:Integer; XYM:String; //a:string; begin //a:='07910584216379105842'; SfzXy:=0; for i:=1 to 17 do begin SfzXy:=SfzXy+StrToInt(Copy(ID,i,1))* iPosPower[i]; // strtoInt(a[i]); Case (SfzXy Mod 11) of 0: XYM :='1'; 1: XYM :='0'; 2: XYM :='X'; 3: XYM :='9'; 4: XYM :='8'; 5: XYM :='7'; 6: XYM :='6'; 7: XYM :='5'; 8: XYM :='4'; 9: XYM :='3'; 10: XYM :='2'; end; end; Result:=XYM; end; |