Can anyone tell me how to write a SIN validation code to ensure valid SIN number entry?
First 8 digits: 1 2 3 4 5 6 7 8
Double the even digits: 4 8 12 16
Cross-add each digit: 4+8+1+2+1+6=22
Add the odd digist: 1+3+5+7=16
Add the results of each: 22+16=38
Subtract this number from the next highest multiple of 10: 40-38=2
2 should be the 9th digit. If it doesn't match, then it is an invalid SIN.
I would create a public function that accepted the number as input, and returned a boolean (true or false). Do your various validations and math and return true/false as appropriate. I suspect you'll make good use of the Mid() function, as well as some others, plus some variables. Here's a primer on functions if you need it: