Thread: Canadian SIN
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
René René is offline
external usenet poster
 
Posts: 4
Default Canadian SIN

I went to a CCRA Office and got the "Payroll Deductions
Formulas for Computer Programs".

It starts on page 23 but the formula is on page 24.

Example

The employee provides SIN 193-456-787

Basic number(first eight digits) check digit

193 456 78 7

Make a number from each alternate position to the left

beginning at the second digit 9 4 6 8
Add the number to itself 9 4 6 8
Sum 18 8 12 16

Cross-add the digits in the sum

(1 + 8 + 8 + 1 + 2 + 1 + 6) = 27

Add each alternate digit beginning at the first digit

(1 + 3 + 5 + 7) = 16

27
16
Total 43

If the total is a multiple of 10, the check digit should
be 0; otherwise, subtract the total calculation (43) from
the next highest number ending with 0 (50) in this case.

The check digit is (50 - 43) = 7

This is how it is writen in the "Payroll Deductions
Formulas for Computer Programs"" from CCRA.

GOOD LUCK

René
-----Original Message-----
Good morning everyone,

On a Useform I have a textbox where the user must enter a
Social Insurance Number (Canadian).

I would like to verify if the number entered is valid.
Someone gave me the following code:

Function NumberValidation(CodeNumber)

Dim E, i, SUBT, TOT, LAST

If (IsNumeric(CodeNumber)) and (Len(CodeNumber) 8)

and
(Len(CodeNumber) < 12) Then
If (Len(CodeNumber) = 11) Then
CodeNumber = Del(CodeNumber, 4, 1)
CodeNumber = Del(CodeNumber, 7, 1)
End If
TOT = 0
For i = 1 To 8
E = mid(CodeNumber,i,1)
If ((i Mod 2) = 0) Then
SUBT = (E * 2)
Else
SUBT = E
End If
If (SUBT 9) Then
SUBT = Mid(SUBT, 1, 1)*1 + Mid(SUBT, 2, 1)
End If
TOT = TOT + SUBT
Next
If (TOT 9) Then
LAST = (10 - ((Mid(TOT, 2, 1))))
Else
LAST = (10 - ((Mid(TOT, 1, 1))))
End If
If (LAST 9) Then LAST = (Mid(LAST, 2, 1))
If Mid(CodeNumber, 9, 1) = Trim(LAST) Then
NumberValidation = True
Else
NumberValidation = False
End If
Else
NumberValidation = False
End If
End Function

However, Excel doesn't seem to like it. It returns an
error message on

CodeNumber = Del(CodeNumber, 4, 1)

Anyone would have an idea why? Or maybe a better
solution ?

Thanks for your help...

Dennis
.