某商场元月举行VIP客户积分换购活动,VIP客户根据卡内积分多少可换取不同额度的代金券。假设VIP客户共有n名,VIP卡内积分存放在数据库“customer.accdb”的Integral表中,换购活动的VB程序代码如下,程序运行时界面如图所示。工作人员在文本框Text1中输入VIP卡号后,单击“换购”按钮Command1,在文本框Text2中输出VIP客户的积分数,在标签Label3中显示可以换购的代金券额度,积分清零。按此要求编写程序如下, 但加框处代码有错,请改正。
Dim ID( ) As String '用于存放客户卡号
Dim total( ) As Long '用于存放积分数
Dim sc As Long 'VIP客户人数
Dim jf As Long '积分数
Private Sub Command1_Click( )
Dim k As String '客户卡号
Dim q As Long '代金券额度
Dim i As Long
k = Text1.Text
For i =" 1" To sc ’顺序查找
If ID(i) =" k" Then
jf = total(i)
cash(jf) = q ’①
Exit For
End If
Text2.Text = Str(jf)
Label3.Caption = “您可换购的代金券总额为:”+ Str(q) + “元”
Next i
End If
End Sub
' cash函数用于计算VIP客户可换购的代金券额度
Function cash(jf As Long) As Long
If jf >=" 2000" And jf <=" 20000" Then
Cash = jf\2000*10
ElseIf jf > 20000 And jf <=" 50000" Then
Cash = jf\2000*11
ElseIf jf > 50000 And jf <=" 100000" Then
Cash = jf\2000*12
ElseIf jf > 100000 And jf <=" 150000" Then
Cash = jf\2000*13
Else jf > 150000 Then ’ ②
Cash = jf\2000*14
End If
End Function
Private Sub Form_Load()
Dim conn As New ADODB.Connection, rs As New ADODB.Recordset
Dim intSQL As Long
conn.ConnectionString = "Provider="Microsoft.ACE.OLEDB.12.0;Data" Source=" + App.Path + "\ customer.accdb"
conn.Open
intSQL = "SELECT score FROM Integral"
Set rs.ActiveConnection = conn
rs.CursorType = adOpenStatic
rs.Open intSQL
sc = 0
Do While Not rs.EOF
sc =" sc" + 1
total(sc) = rs.Fields("score")
rs.MoveNext
Loop
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
End Sub
(1)加框处①有错,应改为_____________________。
(2)加框处②有错,应改为_____________________。