题型:综合题 题类:模拟题 难易度:困难
浙江省普通高校招生信息技术选考模拟卷(四)
现编写一个VB程序,实现如下功能:在文本框Text1中产生条形码数字序列,单击“校验”按钮Command1,在标签Label1中输出对应的校验信息,界面如图所示。实现上述功能的VB程序如下,但加框处代码有错,请改正
Private Sub Command1_Click()
Dim s As String, x As Integer
Dim n As Integer , js As Integer, os As Integer, m As Integer
Js=0: os=0
s = Text1.Text
If n <> 13 Then
Label1.Caption = "条形码位数错误!"
Else
For i = 1 To 12
If x Mod 2 <> 0 Then
js = js + x
Else
os = os + x
End If
Next i
m = os * 3 + js
If m=Val(Mid(s,n,1)) Then
Label1.Caption = "校验码正确!"
Else
Label1.Caption = "校验码错误!"
End If
End If
End Sub
试题篮