[求助]应该从哪下手
我想编一个检验准考证号的程序
例如:我在text1中输入2573458,按command1后text2中显示的数值是1257345
text2中的数是i&text1中的数
i=(8*1+5*2+4*3+3*4+7*5+5*6+2*7)mod10=1
该怎么编?难道要对我输入的七个数字分别定义吗?那又怎么确定我输入的数字就是我定义的数字呢?
感谢!
Option Explicit
Private Sub Command1_Click()
Dim n As String
Dim a As Integer, b As Integer, c As Integer
Dim d As Integer, e As Integer, f As Integer
Dim g As Integer
Dim i As Long
If Len(Text1.Text) <> 7 Then
MsgBox "请输入7个数"
Exit Sub
End If
n = Text1.Text
a = Left(n, 1): b = Mid(n, 2, 1): c = Mid(n, 3, 1)
d = Mid(n, 4, 1): e = Mid(n, 5, 1): f = Mid(n, 6, 1)
g = Right(n, 1)
i = (g * 1 + f * 2 + e * 3 + d * 4 + c * 5 + b * 6 + a * 7) Mod 10
Text2.Text = CStr(i) & Text1.Text
End Sub
Private Sub Form_Load()
Text1.MaxLength = 7
End Sub