计算机类二级VB

二级VB上机题库35

10 题含答案VB
共 10 题返回本类
2材料分析题2 / 10
  
查看答案
Private Sub Command1_Click()
  Label1.FontSize = Label1.FontSize - 2
End Sub
Private Sub Command2_Click()
  Label1.FontSize = 12
End Sub
3材料分析题3 / 10
   
Option Base 1
Dim a(30) As Integer
Private Sub Cmd1_Click()
    Open App.Path & "\in3.dat" For Input As #1
    For m = 1 To 30
      Input #1, a(m)
      Text1 = Text1 + Str(a(m)) + Space(2)
    Next m
    Close #1
End Sub
Private Sub Cmd2_Click()
  Dim num As Integer, n As Integer
  num = InputBox("请输入待查找的数")
' If num / 2  ?  Fix(num / 2) Then
      MsgBox "输入数为奇数,请重输!", , "检查"
      Exit Sub
  End If
' If num < a(1)  ?  num > a(30) Then
      Text2.Text = Str(num) + "已超出所给数值范围"
      Exit Sub
  End If
  For n = 1 To 30
    ' If a(n) =  ?  Then
        Text2.Text = Str(num) + "是数组中的第" + Str(n) + "个值"
        Exit For
      End If
  Next n
  'If n  ?  30 Then
      Text2.Text = Str(num) + "不存在于数组中"
  End If
End Sub
查看答案
If num / 2  <>  Fix(num / 2) Then
If num < a(1)  Or  num > a(30) Then
    If a(n) =  num  Then
  'If n  >  30 Then
4材料分析题4 / 10
   
Option Base 1
Dim a(20, 3) As Integer
Private Sub Command1_Click()
    Open App.Path & "\in4.dat" For Input As #1
    For i = 1 To 20
      For j = 1 To 3
          Input #1, a(i, j)
          Text1 = Text1 + Str(a(i, j)) + Space(4)
      Next j
      Text1 = Text1 + Chr(13) + Chr(10)
    Next i
    Close #1
End Sub
Private Sub Command2_Click()
  Dim x(3) As Integer
  For i = 1 To 20
'    ? = (a(i, 2) + a(i, 3)) / 2
      Select Case Avg
'        Case ?
            x(1) = x(1) + 1
'        Case ?
            x(2) = x(2) + 1
        Case Is < 60
            x(3) = x(3) + 1
'    ?
  Next i
  For n = 1 To 3
'    Text2( ? ) = x(n)
  Next n
End Sub
查看答案
    Avg = (a(i, 2) + a(i, 3)) / 2
        Case Is >= 85
        Case Is >= 60
    End Select
    Text2( n-1 ) = x(n)
5材料分析题5 / 10
   
Option Base 1
Dim a(20, 5) As Integer
Private Sub Command1_Click()
    Open App.Path & "\in5.dat" For Input As #1
    For i = 1 To 20
      For j = 1 To 5
          Input #1, a(i, j)
          Text1 = Text1 + Str(a(i, j)) + Space(2)
      Next j
      Text1 = Text1 + Chr(13) + Chr(10)
    Next i
    Close #1
End Sub
Private Sub Command2_Click()
‘考生编写
=============
???
=============
Private Sub Form_Unload(Cancel As Integer)
    Open App.Path & "\out5.dat" For Output As #1
    Print #1, Text2.Text
    Close #1
End Sub
查看答案
Dim b(20) As Integer
  For i = 1 To 20
    For j = 1 To 5
      b(i) = b(i) + a(i, j)
      b(i) = b(i) / 5
    Next j
  Next i
  For i = 2 To 20
    Max = b(1)
    If b(i) > Max Then
      Max = b(i)
    End If
  Next i
  Text2.Text = MaxEnd Sub
7材料分析题7 / 10
  
查看答案
Private Sub Command1_Click()
  List1.AddItem List1.Text
End Sub
Private Sub Command2_Click()
  List1.RemoveItem List1.ListIndex
End Sub
8材料分析题8 / 10
   
Dim flag As Integer
Private Sub Form_Load()
  flag = 0
End Sub
Private Sub Command1_Click()
  If Command1.Caption = "移动" Then
'    Timer1.Enabled = ?
    Command1.Caption = "暂停"
  Else
    Timer1.Enabled = False
    Command1.Caption = "移动"
  End If
End Sub
Private Sub Command2_Click()
  End
End Sub
Private Sub Timer1_Timer()
  Select Case flag
      Case Is = 0
'        Label1.Left = Label1.Left  ?  100
        If Label1.Left + Label1.Width > = Form1.Width Then flag = 1
      Case Is = 1
'        Label1.Left = Label1.Left  ?  100
        If Label1.Left < = 0 Then flag = 0
  End Select
End Sub
查看答案
    Timer1.Enabled = True
        Label1.Left = Label1.Left  +  100
        Label1.Left = Label1.Left  -  100
9材料分析题9 / 10
   
Private Sub Command1_Click()
  If Len(Text1) = 0 Then
      MsgBox "选手编号不能为空,请检查!", , "检查"
      Exit Sub
  End If
  For n = 0 To 9
      If Len(Text2(n)) = 0 Then
        MsgBox "评委给分不能为空,请检查!", , "检查"
        Exit Sub
      End If
  Next n
  Max = Val(Text2(0)): Min = Val(Text2(0))
  Sum = Val(Text2(0))
'  For n = ?  To 9
      Select Case Val(Text2(n))
'          Case Is  ?  Max
            Max = Text2(n)
'          Case Is  ?  Min
            Min = Text2(n)
      End Select
'      Sum =  ?  + Val(Text2(n))
  Next n
  score = (Sum - Max - Min) / 8
  Picture1.Print Text1; Space(5); score
  Text1 = ""
  For n = 0 To 9
      Text2(n) = ""
  Next n
End Sub
查看答案
  For n = 0  To 9
          Case Is  >  Max
          Case Is  <  Min
      Sum =  Sum  + Val(Text2(n))
10材料分析题10 / 10
   
Option Base 1
Dim a(20, 5) As Integer
Private Sub Command1_Click()
    Open App.Path & "\in5.dat" For Input As #1
    For i = 1 To 20
      For j = 1 To 5
          Input #1, a(i, j)
          Text1 = Text1 + Str(a(i, j)) + Space(2)
      Next j
      Text1 = Text1 + Chr(13) + Chr(10)
    Next i
    Close #1
End Sub
Private Sub Command2_Click()
'===============考生编写程序开始======================
???
'===============考生编写程序结束======================
End Sub
Private Sub Form_Unload(Cancel As Integer)
    Open App.Path & "\out5.dat" For Output As #1
    Print #1, Text2.Text
    Close #1
End Sub
查看答案
  Dim min(20) As Integer
  For i = 1 To 20
    min(i) = a(i, 1)
    For j = 1 To 5
      If a(i, j) < min(i) Then
        min(i) = a(i, j)
      End If
    Next j
  Next i
  For i = 1 To 20
    Sum = Sum + min(i)
  Next i
  ave = Sum / 20
  Text2.Text = ave
← 上一卷下一卷 →