当前位置: 高中信息技术 / 综合题
  • 1. (2017高三上·浙江月考) 【加试题】中秋节时,班级组织活动,其中有抽奖环节,小龙在7选3中选考了技术,班主任让小龙编写一个VB抽奖程序,功能如下:窗体装载过程从数据库读取所有同学的相关数据并显示在列表框List1中,抽奖时在文本框Text1中输入要抽出的人数,单击“摇奖”按钮command1,程序进行处理,结果输出在列表框list2中。程序运行界面如下图所示。

    实现上述功能的VB程序如下,请回答下列问题:

    1. (1) 分析下面的程序代码,可知数据表名为
    2. (2) 请在划线处填入合适的代码。

      Dim a(1 To 100) As String '数组大小满足处理要求,学生学号

      Dim b(1 To 100) As String '数组大小满足处理要求,学生姓名

      Dim i As Integer '学生总数

      Dim j As Integer

      Dim dd(1 To 100) As Integer

      Private Sub Form_Load()

      ‘从数据库读取全班同学的相关信息,存储在数组a、数组b和变量i中

          Dim n As Integer

      Dim conn As New ADODB.Connection

      Dim rs As New ADODB.Recordset

      Dim strSQL As String

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

      conn.Open

      Set rs.ActiveConnection = conn

      strSQL = "SELECT * FROM stuinfo"

      rs.Open strSQL

      '本过程的其他语句略

      End Sub

      Private Sub Command1_Click()

          Dim ShuruNum As Integer, k As Integer, y As Integer,n As Integer

          Randomize

          ShuruNum = Val(Text1.Text)

          Label4.Caption = ""

          For k = 1 To i

            dd(k) = 0

          Next k

          If ShuruNum > 0 And ShuruNum <= i Then

              j = 1

              Do While j <= ShuruNum

                  y = Int(Rnd() * i) + 1

                  If   Then'

                      dd(j) = y

                      j = j + 1

                  End If

              Loop

              List2.Clear

              For n = 1 To ShuruNum

                  List2.AddItem   '

              Next n

          Else

              Label4.Caption = "错误:没有输入中奖人数或超过学生总数"

          End If

      End Sub

      '核对重复,避免同一人再次中奖

      Private Function CheckCF(p As Integer) As Boolean

          Dim m As Integer,x As Boolean

          x = True '初始化

          For m = 1 To j

              If   Then '

                  x = False

                  Exit For

              End If

          Next m

          CheckCF = x

      End Function

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