试题

试题 试卷

logo

题型:综合题 题类:常考题 难易度:困难

浙江省杭州市2016年信息技术高考模拟卷一

某超市举行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 Command1Click( )

  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

                                     ’ ②

      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

ElseIf jf > 150000 Then

       Cash = jf\2000*14

End If

End Function


Private Sub FormLoad()

   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)、横线处②,应填入的语句是
举一反三
小月设计了一个VB程序,用于对全班55名同学的体质调查分析,该程序能将55名同学的身高与体重录入到数据库中,之后通过如图所示的VB应用程序计算出这些同学的BMI指数,并按BMI指数从小到大进行排序,并显示这些学生的体质情况。

    注:BMI指数的计算公式为:BMI=体重(千克)除以身高(米)的平方(kg/m2)。 BMI<18.5为偏瘦(表明营养不足);BMI=18.5~24.9为体重正常;BMI=25~29.9为超重;BMI>30为肥胖。

该VB应用程序的代码如下:

Dim stuBMI(1 To 55) As Single

Dim stuName(1 To 55) As String

Private Sub Command1_Click()

    Dim k As Integer, i As Integer, j As Integer

    Dim t1 As Single, t2 As String

    Dim Results As String

    For i = 1 To 54        

        For j = i + 1 To 55

            If stuBMI(j) < stuBMI(k) then      ②    

        Next j

        If  k<>I  Then  

            t1 = stuBMI(i): stuBMI(i) = stuBMI(k): stuBMI(k) = t1

            t2 = stuName(i): stuName(i) = stuName(k): stuName(k) = t2

        End If

    Next i

List1.AddItem "姓名" + vbTab + "BMI指数" + vbTab + "结果"  

    For i = 1 To 55

        If stuBMI(i) < 18.5 Then

            Results = "偏瘦"

        ElseIf stuBMI(i) >= 18.5 And stuBMI(i) < 25 Then

            Results = "正常"

        ElseIf stuBMI(i) >= 25 And stuBMI(i) < 30 Then

            Results = "超重"

        Else

            Results = "肥胖"

        End If

        List1.AddItem stuName(i) + vbTab + str(stuBMI(i)) + vbTab + Results

    Next i

End Sub

Private Sub Form_load()

    Dim conn As New ADODB.Connection

    Dim rs As New ADODB.Recordset

    Dim strSQL As String

    Dim i As Integer

    conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + App.Path + "\Student.accdb"

    conn.Open

    strSQL = "SELECT * FROM Student"

    Set rs.ActiveConnection = conn

    rs.Open strSQL

    i = 0

    Do While Not rs.EOF

        i = i + 1

        stuName(i) = rs.Fields("StuName")

        stuBMI(i) = Round(rs.Fields("Weight") / rs.Fields("height") ^ 2, 1)

        rs.MoveNext

    Loop

    rs.Close

    conn.Close

    Set rs = Nothing

    Set conn = Nothing

End Sub

杭州市民卡是由杭州市人民政府授权发放给市民用于办理个人相关事务和享受公共服务的集成电路卡(IC卡),具有信息储存、身份识别、电子支付等功能。每位市民卡的卡号是唯一的,卡内会记录每位市民的姓名、住址、金额等信息。

        假设共有1000个市民,市民的相关信息都存储在“information.accdb”的data表中,查询程序界面如图所示。工作人员在文本框Text1中输入卡号,单击“开始查询”按钮,如果找到,就在Label1中显示卡内市民姓名和卡内余额;否则显示“查无此人”。请按要求将下列程序补充完整。

Private Sub command1_click()

Dim conn As New ADODB.Connection, rs As New ADODB.Recordset

Dim strSQL As String

Dim a,b as string ‘分别定义姓名、余额

Dim n as integer

conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + App.Path + "\information.accdb"     '打开到数据库的链接

 conn.Open

strSQL ="select xh,xm from data where '卡号=&(Text1.Text) & '" '设置查询的SQL语句

 Set rs.ActiveConnection = conn      '设置rs的ActiveConnection属性,指定与其关联的数据库链接

  rs.Open strSQL   '打开记录集,将从表information中读取的结果保存到记录集rs中

  Label1.Caption = ""

n=0

Do while not rs.EOF

       ①        

a=rs.Fields("姓名")

 b=rs.Fields("余额")

rs.movenext

loop

rs.Close

  conn.close

set rs=nothing

set conn=nothing

             ②       

if n=0 then Label1.caption="查无此人"

End Sub

返回首页

试题篮