Dim
tno() = {10, 11, 12, 13, 14, 15, 16, 17, 34, 18, 19, 20, 21, 22, 35, 23, 24,
25, 26, 27, 28, 29, 32, 30, 31, 33}
‘
A B
C D E
F G H
I J K
L M N
O P Q
R S T
U V W
X Y Z
Function
M1P31(ByVal pid As String) As String
If
(pid.Length <> 10) Then Return "F" '非
10 個字元
Dim c
As Char = Mid(pid, 1, 1)
' 是否為英文字母
If c
< "A" Or c > "Z" Then Return "F" '第1個字為大寫字母
Dim num
As Integer = tno(Asc(c) - 65) '-Asc("A") 'A=0 從 tno()陣列找對應的
Dim SUM
As Integer = (num \ 10) * 1 + (num Mod 10) * 9
c =
Mid(pid, 2, 1)
' 是否為
1 或 2
If c
< "1" Or c > "2" Then Return "F" '第2個字為 1 或 2
SUM +=
(Asc(c) - 48) * 8
For i =
3 To 9 '第3~9需數字
c =
Mid(pid, i, 1)
If
c < "0" Or c > "9" Then Return "F"
SUM
+= (Asc(c) - 48) * (10 - i) '分別乘
7 ~ 1
Next
c =
Mid(pid, 10, 1) '最後一個是檢查碼 ,再加上去可被10整除才對
If c
< "0" Or c > "9" Then Return "F"
SUM +=
(Asc(c) - 48)
If SUM
Mod 10 = 0 Then Return "T" Else Return "F"
End
Function
----------------------
|
in1.txt
----------------------
3
M123456789
Y123456788
A223344556
----------------------
in2.txt
----------------------
3
R102345678
A108881111
B101111111
----------------------
out.txt
----------------------
T
T
F
T
F
T
0 意見:
張貼留言