vb.net Luhn Check digit

shooter69

Expert Member
Joined
Jun 4, 2012
Messages
3,390
Reaction score
941
Location
Dark Africa
Hi,

I am calculating a check digit using the Luhn algorithm. How would I put the following in code?

checkdigit = ((sum / 10 + 1) * 10 – sum) % 10

The C++ code is as follows : ((Math.Floor((decimal) sum/10) + 1)*10 - sum)%10;

I am having a problem with the "% 10". what is this and how do I work with it in .net?

http://www.darkcoding.net/credit-card/luhn-formula/
 
Last edited:
Hi,

I am calculating a check digit using the Luhn algorithm. How would I put the following in code?

checkdigit = ((sum / 10 + 1) * 10 – sum) % 10

The C++ code is as follows : ((Math.Floor((decimal) sum/10) + 1)*10 - sum)%10;

I am having a problem with the "% 10". what is this and how do I work with it in .net?

http://www.darkcoding.net/credit-card/luhn-formula/

It's the modulus operator, returns the remainder of one number or expression divided by another.

Use Mod instead of % in VB.NET.
 
Top
Sign up to the MyBroadband newsletter
X