Hi guys,

I need to make a checksum procedure. Can someone help me?

I have a 15 digit number:

Num:=220840001229500

The last 2 digits are zeroes by default.

To get a "control number" I have to perform the following calculation:

I divide Num with 97, thats:

220840001229500:97=2276701043603.09xxxx

Now I have to use the second digit of this result - the 9.

(97+1)-9=89

So 89 is my "control number",

and now at the end, Num: the last 2 zeroes get replaced with the "control number" and Num2: would be

Num2:=2208400012295/89

Greetings, Blash

What you need then is this:

procedure TForm1.Button1Click(Sender

FUNCTION BigStrToInt(sValue : STRING): INT64;

VAR

iCount : LONGINT;

BEGIN

Result := 0;

FOR iCount := 1 TO Length(sValue)

DO

Result := Result * 10 + StrToInt(sValue[iCount]);

END;

VAR

iValue : INT64;

iResult : INT64;

sValue : STRING;

begin

sValue := '220401000207682';

//Get the stribg into an integer

iValue := BigStrToInt(sValue);

//We're only interested in the final two digits for calculating the checksum

//BUT we need remember the rest of the value (minus the last two digits) so

//strip off the last two digitd by dividing by 100

iResult := iValue DIV 100;

//Divide the COMPLETE value by 97

iValue := ((iValue DIV 100) * 100) MOD 97;

//Calculate the checksum

iValue := (97 + 1) - iValue;

//Add the two checksum digits to the end of the value

//iResult is the original number but with the last two digits stripped. If we

//add on two extra zeroes (by multiplying by 100), we can then add the

//checksum value straight onto the end to give us a final value

iResult := iResult * 100 + iValue;

ShowMessage('Result: ' + IntToStr(iResult));

end;

Although it looks to be just about the same code, it's now replacing the final two dogits with zeroes BEFORE doing the checksum calculation. After it's done the calculation it then just replaces the final two dogots with the checksum value. Hope that's what you needed

The Neil =:)