若拒绝修订,则第三句的文字将变为( )
下列说法正确的是( )
For i = 5 To 4 Step -1
k = i
For j = 6 - i To 1 Step -1
If a(j) < a(k) Then k = j
Next j
If i <> k Then
t = a(i): a(i) = a(k): a(k) = t
End If
Next i
数组元素a(1)到a(5)的值依次为“41,66,70,83,31”,经过该程序段“加工”后,数组元素a(1)到a(5)的值依次为( )
图b
图c
Private Sub Com_Click()
Dim pv As Single, fv As Single, rate As Single, n As Integer
pv = Val(Te1.Text)
fv = Val(Te2.Text)
rate = Val(Te3.Text) / 100
n = 1
Do While
pv = pv * (1 + rate)
List1.AddItem "第" + Str(n) + "年" + " " + Str(pv) + "元"
n = n + 1
Loop
Te4.Text =
End Sub
请在程序的划线处填写合适的代码。
Private Sub Command1_Click()
Dim a As String,s As String
Dim r As Integer,x As Integer
x = Val(Text1.Text)
s = ""
Do While x > 0
▲ ‘①
x = x \ 16
If r > 9 Then
a = Chr(r + 55)
Else
a = Str(r)
End If
▲ ‘②
Loop
Text2.Text = s
End Sub
①把身份证前 17 位的每个数字和加权系数相乘并累加求和。身份证号码前17位数的加权系数见下表:
身份证号位数 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
加权系数 | 7 | 9 | 10 | 5 | 8 | 4 | 2 | 1 | 6 | 3 | 7 | 9 | 10 | 5 | 8 | 4 | 2 |
②根据步骤①求得的和值,与11做取余运算得到序号,再根据序号提取校验码字符。如:所得和值除以11的余数为“0”,则对应的校验码为“1”。如下表:
序号 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
校验码 | 1 | 0 | X | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 |
若步骤②中提取的校验码和身份证号最后一位相同,则校验通过,否则校验失败。
某人根据上述原理设计了一个身份证校验VB程序,功能如下:程序启动时从数据库student.accdb中读入全校学生身份证数据(全校共15个班级),并在列表框List1中显示,单击“校验”按钮Command1,在列表框List2中输出各班身份证号出错学生的信息和出错人数,若某班无出错学生,则不显示。程序界面如图所示。实现上述功能的VB程序如下,请回答下列问题:
Const max = 1000
Dim n As Integer '存放学生人数
Dim sfzh(1 To max) As String, xm(1 To max) As String
'数组sfzh、xm分别存放学生身份证号、姓名
Dim bj(1 To max) As Integer, flag(1 To max) As Boolean
'数组bj、flag分别存放学生班级、身份证校验结果
Dim cw(1 To 15) As Integer '数组cw存放各班身份证号出错人数
Function check(x As String) As Boolean
'本函数功能:校验身份证号x,若校验通过返回True;否则返回False
Dim i As Integer, sum As Integer, xh As Integer, jym As String
Dim a(1 To 18) As Integer, w(1 To 18) As Integer
jym = "10X98765432" : sum = 0
For i = 18 To 2 Step -1
a(i) = Val(Mid(x, 19 - i, 1))
Next i
For i = 18 To 1 Step -1
w(i) = 2 ^ (i - 1) Mod 11
Next i
For i = 2 To 18
sum = sum + a(i) * w(i)
Next i
xh = sum Mod 11
If = Mid(x, 18, 1) Then check = True Else check = False
End Function
Private Sub Form_Load()
'本过程从数据库中读入指定数据到数组sfzh、xm、bj,并在List1中显示
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
conn.ConnectionString = "provider=microsoft.ace.oledb.12.0;data source=" + App.Path + "\student.accdb"
conn.Open
Set rs.ActiveConnection = conn
rs.Open "select * from stu"
'本过程其它语句略,学生人数存变量n,数组cw各元素初值置为0
End Sub
Private Sub Command1_Click()
Dim i As Integer, j As Integer
For i = 1 To n
If check(sfzh(i)) Then flag(i) = True Else flag(i) = False
Next i
For i = 1 To 15
For j = 1 To n
If bj(j) = i And flag(j) = False Then
List2.AddItem sfzh(j) + " " + xm(j)
End If
Next j
If cw(i) > 0 Then
List2.AddItem Str(i) + "班共有以上" + Str(cw(i)) + "个身份证号错误"
List2.AddItem ""
End If
Next i
End Sub