반응형
<%
Function check_cn(cn)
Dim result
Dim cn_chk
Dim i
Dim sum
sum = 0
Dim cn_array(10)
Dim chk_val(9)
chk_val(1) = 1
chk_val(2) = 3
chk_val(3) = 7
chk_val(4) = 1
chk_val(5) = 3
chk_val(6) = 7
chk_val(7) = 1
chk_val(8) = 3
chk_val(9) = 5
For i = 1 to 10
cn_array(i) = CInt( mid(cn, i, 1))
Next
For i = 1 to 9
sum = sum + cn_array(i) * chk_val(i)
Next
sum = sum + ( cn_array(9) * 5) / 10
result = sum mod 10
If result = 0 Then
cn_chk = 0
Else
cn_chk = 10 - result
End IF
If cn_chk = cn_array(10) Then
check_cn = true
Else
check_cn = false
End If
End Function
i = check_cn("1234567890")
Response.Write i
%>