10 Years of Service
15%
Please note, if you want to make a deal with this user, that it is blocked.
[HIDE-THANKS]Verifies social insurance number (Canadian equivalent of SSN) and returns either true or false.
[/HIDE-THANKS]
Code:
>'updated code.....
==
' This function verifies the social insurance number
' (Canadian equivalent of SSN) and returns true if
' the number is valid, false if the number is invalid.
' Here's how to verify the number.
' SIN: 1 2 3 4 5 6 7 8 2
' 1. Take the number in the even position and
' multiply by 2.
' 2X2=4, 4X2=8, 6X2=12, 8X2=16
' 2. Take number from step 1 and add each digit.
' (ie. If the number is 12, then add 1 and 2 to get 3)
' 4+8+1+2+1+6 = 22
' 3. Take the number in the odd position and
' add them, not including the check digit (9th digit).
' 1+3+5+7 = 16
' 4. Add the two numbers from step 2 and step 3.
' 22 + 16 = 38
' 5. Subtract the number from Step 4 from the next highest
' number ending with 0 (ie. 40). This number should be
' your last digit of your SIN.
' 40 - 38 = 2 <-- Does this number match the 9th digit?
'
' See http://www.qp.gov.bc.ca/pserc/chips/Manual/Sin2.htm for
' more information.
Private Function Verify_SIN(strSIN As String) As Boolean
Dim intCount As Integer
Dim intEven As Integer
Dim intOdd As Integer
intEven = 0
intOdd = 0
' If the input is not 9 digits or if the input is non numeric
' reject.
If (Len(strSIN) <> 9) Or Not (IsNumeric(strSIN)) Then
Verify_SIN = False
Exit Function
End If
For intCount = 1 To 8
' intCount is even
If (intCount Mod 2) = 0 Then
' If the multiplied value is greater than 10,
' take the last digit and add 1.
If (Val(Mid(strSIN, intCount, 1)) * 2) >= 10 Then
intEven = intEven + ((Val(Mid(strSIN, intCount, 1)) _
* 2) - 10) + 1
Else
intEven = intEven + Val(Mid(strSIN, intCount, 1)) * 2
End If
' intCount is odd
Else
' Add the number is odd position.
intOdd = intOdd + Val(Mid(strSIN, intCount, 1))
End If
Next
' Take the result and compare with the 9th digit.
If Trim((Str((10 - ((intEven + intOdd) Mod 10)) Mod 10))) = _
Mid(strSIN, 9, 1) Then
Verify_SIN = True
Else
Verify_SIN = False
End If
End Function