Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int getEAN13CheckSum(string strData)
- {
- int iLen = strData.Length;
- int i = 0;
- int result = 0;
- int getSum = 0;
- string parseStr = strData.Trim();
- string CharInt = "";
- while (parseStr.Length != 0) // (iLen - 1))
- {
- CharInt = ClsReusable.Left(parseStr, 1); // Len: 1 - Line Size ( Trim first two character )
- parseStr = ClsReusable.Right(parseStr, parseStr.Length - 1);
- if ((i % 2) == 0)
- result = Convert.ToInt32(CharInt) * 1; //Even num Position
- else
- result = Convert.ToInt32(CharInt) * 3; //Odd num Position
- i = i + 1;
- getSum = result + getSum;
- result = 0;
- }
- if (getSum.ToString().Length == 1) { return (getSum - 10); }
- if (getSum.ToString().Length > 1)
- {
- return (10 - (getSum % Convert.ToInt32(ClsReusable.Left(getSum.ToString(), getSum.ToString().Length - 1) + "0")));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment