假设共有500个市民,市民的相关信息都存储在“information.accdb”的data表中,”xm, ye,kh” 字段放市民的姓名,余额,卡号。查询程序界面如第16题图所示。工作人员在文本框Text1中输入卡号,单击“查询”按钮,如果找到,就在Label1中显示卡内市民姓名和卡内余额;否则显示“查无此人”。程序如下,请按要求将程序补充完整。
Private Sub command1_click()
Dim conn As New ADODB.Connection, rs As New ADODB.Recordset
Dim strSQL As String
Dim a,b,c as string
Dim n as integer
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + App.Path + "\ ① "
conn.Open
strSQL ="select * from data"
Set rs.ActiveConnection = conn
rs.Open strSQL
Label1.Caption = ""
c=val(text1.text)
n=0
rs.movefirst
Do while not rs.EOF
n=n+1
a=rs.Fields("xm")
②
If c= rs.Fields("kh") then
Label1.caption=a+ "的卡内余额为"+b+"元"
Exit if
else
rs.movenext
end if
loop
if n=500 then Label1.caption=”查无此人”
rs.close
conn.close
set rs=nothing
set conn=nothing
End Sub