全部变成数字就好判断了。取最后一位,判断最后一位是不是X,如果是吧最后一位当数字10即可,对你代码修改(仅command1_click和form_load部分)后如下:
Dim a(16) As Integer, b, c, d, w, h As Byte
Private Sub Command1_Click()
Dim s
Form_Load
y = T1.Text
For i = 0 To 16
a(i) = Val(Mid(y, i + 1, 1))
s = s + a(i) * b(i)
Next
w = UCase(Right(y, 1))
If w = "X" Then w = "10"
s = s Mod 11
If d(s) = Val(w) Then
MsgBox "此身份验证正确!请放心使用!", , "验证完毕"
Else
MsgBox "此身份验证不合格!请拘捕此人!", , "验证完毕"
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
b = Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2)
d = Array(1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2)
Form1.Width = 4786
Form1.Height = 3480
End Sub
Private Sub T1_KeyDown(KeyCode As Integer, Shift As Integer)
If T1.Text <> "" Then Command1.Enabled = True
End Sub
Private Sub T1_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then
Unload Me
ElseIf KeyAscii = 13 Then
Command1_Click
End If
End Sub
Private Sub Timer1_Timer()
Randomize
L2.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
L2.Left = L2.Left - 70
If L2.Left < -3000 Then L2.Left = 4300
End Sub