Public Shared Function CheckSumDigit(ByVal id As String) As Integer
'// Check input data length
If Len(id) <> 3 Then
Return 0
End If
Dim digit(3) As Integer
Dim z As Integer
For z = 1 To 3
digit(z) = id.Substring(z - 1, 1)
Next
Dim A, B, C, D, E, F, G, H, I, J As Integer
A = digit(1) + digit(3) + digit(5) + digit(7) + digit(9) + digit(11)
B = IIf((digit(2) * 2) > 9, digit(2) * 2 - 9, digit(2) * 2)
C = IIf((digit(4) * 2) > 9, digit(4) * 2 - 9, digit(4) * 2)
D = A + B + C
E = H Mod 3
F = IIf(3 - E = 3, 0, 3 - E)
Return F
End Function