当前位置: 高中信息技术 / 综合题
  • 1. (2021高三上·浙江期中) 高考期间,为了提高学生的学习效率和保证膳食营养,学校开展“教室就餐”,食堂提供A/B/C/D四种套餐,学生通过网络订餐,订餐后的数据都存在数据库中,套餐字母均为大写。现需要设计一程序,在窗体加载时,读取数据库中学生的订餐情况,并按班级编号升序排列,以班级+姓名+订餐情况输出至列表框List1中,在文本框Text1中输入班级,单击命令按钮Command1统计该班级的订餐情况,程序运行如图所示。

    1. (1) 分析如下程序,可知数据库的文件名为
    2. (2) 实现上述功能的VB程序如下,请在划线处填入合适代码。

      Dim xm (1 To 1000) As String, bj(1 To 1000) As Integer

      Dim tc1 (1 To 1000) As String, tc2(1 To 1000) As String ,n As Integer

      Private Sub Form Load( )

      '从数据库中按班级、学号有序地读取学生的姓名、班级、中午套餐、晚上套餐,依次存入xm、bj、tc1、tc2数组中,总人数存入n中,部分代码如下,其余代码略

          Dim conn As New ADODB.Conncction

          Dim rs As New ADODB.Recordset

          conn ConncctionString = "provider=Microsoft.ACE.OLEDB.12.0;data source=" + "jiucan.accdb"

          conn.Open

          Set rs.ActiveConnection = conn

      End Sub

          Private Sub Command1_Click()

          Dim k As Integer, i As Integer, t As Integer, m As Integer, s1 As String, s2 As Integer Dim zc (1 To 4) As Integer, wc (1 To 4) As Integer      '用于统计套餐数量

          Dim bs (0 To 20) As Integer , ljs (0 To 20) As Integer

          t = Val (Text1. Text):m = 0

          For i = 1 To 4          '为数组赋初始值

              zc(i) = 0: wc(i) = 0

          Next i

          For i = 0 To 20         '为数组赋初始值

              bs(i) = 0: ljs(i) = 0

          Next i

          For i = 1 To n – 1            '按班级编号进行升序排序

             

              For j = i To n- 1

                  If bj(j) < bj(k) Then k = j

              Next j

              s1 = xm(i): xm (i) = xm (k): xm (k) = s1

              s2 = bj(i): bj (i) = bj (k): bj (k) = s2

      s1 = tc1(i): tc1 (i) = tc1 (k): tc1 (k) = s1

              s1 = tc2(i): tc2 (i) = tc2 (k): tc2 (k) = s1

              bs(bj(i)) = bs(bj(i)) + 1

              If bs(bj(i)) = 1 Then

          Next i

          bs(bj(i)) = bs(bj(i)) + 1

          For i = 1 To m

             

          Next i

          For i = ljs(t) - bs(t) + 1 To ljs(t)

      zc(fx(tc1(i))) = zc(fx(tc1(i))) + 1

              wc(fx(tc2(i))) = wc(fx(tc2(i))) + 1

          Next i

          '查询班级的用餐情况,在列表框 List 中输出,代码略

      End Sub

      Function fx(a As String) As Integer

         

      End Function

微信扫码预览、分享更方便