试题

试题 试卷

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

某次考试的流程为先笔试再面试,笔试成绩达到面试资格线的可以入围参加面试。入围面试的资格线根据计划录取人数的200%划定,即如果考试最终录取x人,则第2*x名选手的笔试分数为面试资格的分数线(该分若有同分者可一同参与面试)。现在编写VB程序功能如下:自动读取数据库中考生考号和笔试成绩,依次存储在数组kh(i)、cj(i)中,并显示在List1列表框中。单击“入围划线”按钮Command1,面试分数线显示在文本框Text2中,入围面试最终人数显示在Text3中,进入面试的考生的考号和笔试成绩显示在List2列表框中,如果成绩相同,则按考号由小到大的顺序显示。程序界面如图所示。

 

Dim kh(1 to 500) As string,cj(1 to 500) As Integer Dim n As Integer    ‘参加考试总人数

Private Sub Form_Load()

Dim conn as new ADODB.connection:Dim rs As New ADODB.Recordset

conn.ConnectionString=“Provider=Microsoft.ACE.OLEDB.12.0;Data Source=”

+App.Path+”\BSCJ.accdb”

conn.Open

set rs.activeconnection=conn

rs.Open“select*FROM scoreinfo”

‘本过程其他代码略 End Sub

Private Sub Command1_Click()

Dim m As Integer,i As Integer,j As Integer

Dim t1 As Integer,t2 As String,flag As Boolean For i = 1 To n-1    ‘排序

For j =      ①         If cj(i)<cj(j) Then

t1 = cj(i):cj(i) = cj(j):cj(j) = t1

t2 = kh(i):kh(i) = kh(j):kh(j) = t2 Elseif cj(i) = cj(j) And kh(i) > kh(j) Then

t2 = kh(i):kh(i) = kh(j):kh(j) = t2

End If Next j

Next i

m =         ②        

If m <= n Then   ‘统计进入面试人数

i = m

flag = False

Do While        ③        If cj(i) = cj(i+1) Then

i = i+1 Else

flag = True End If

Loop

Text2.text = Str(cj(m)) Text3.text = Str(i)

For j = 1 To i

List2.AddItem kh(j) + “ ” + Str(cj(i)) Next j

Else

Text2.Text=”面试人数超过总人数了” End If

End Sub

返回首页

试题篮