计算机类二级VB

二级VB上机题库10

10 题含答案VB
共 10 题返回本类
1材料分析题1 / 10
  
查看答案
Private Sub Clea_Click()
  Cls
End Sub
Private Sub Dis_Click()
  Print "等级考试"
End Sub
VERSION 5#
Begin VB.Form Form1
  Caption = "Form1"
  ClientHeight = 3195
  ClientLeft = 165
  ClientTop = 735
  ClientWidth = 4680
  LinkTopic = "Form1"
  ScaleHeight = 3195
  ScaleWidth = 4680
  StartUpPosition = 3    '窗口缺省
  Begin VB.Menu Op
      Caption = "操作"
      Begin VB.Menu Dis
        Caption = "显示"
      End
      Begin VB.Menu Clea
        Caption = "清除"
      End
  End
End
Private Sub Clea_Click()
  Cls
End Sub
Private Sub Dis_Click()
  Print "等级考试"
End Sub
3材料分析题3 / 10
   
  
查看答案
Private Sub Form_Unload(Cancel As Integer)
    Open App.Path & "\out3.txt" For Output As #1
    Print #1, Op1.Value, Op2.Value, Op3.Value, Op4.Value, Text1.Text
    Close #1
End Sub
Private Sub Text1_Click()
    If Op1 And Op3 Then
        Text1.Text = "坐汽车去青岛"
    ElseIf Op1 And Op4 Then
        Text1.Text = "坐汽车去大连"
    ElseIf Op2 And Op3 Then
        Text1.Text = "坐轮船去青岛"
    ElseIf Op2 And Op4 Then
        Text1.Text = "坐轮船去大连"
    End If
End Sub
4材料分析题4 / 10
  
查看答案
Private Sub Form_Click()
    If Op1 Then
        Lab1.Caption = Text1.Text
        Text1.Text = Text2.Text
        Text2.Text = Lab1.Caption
        Lab1.Caption = "交换成功"
    ElseIf Op2 Then
        Lab1.Caption = Text1.Text & Text2.Text
    End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
    Open "out4.txt" For Output As #1
    Print #1, Op1.Value, Op2.Value, Text1.Text, Text2.Text, Lab1.Caption
    Close #1
End Sub
5材料分析题5 / 10
   
' 提供给考生的程序
Option Base 1
Dim Arr1(20) As Integer
Dim Arr2(20) As Integer
' 提供给考生的程序
Sub ReadData1()
    Open App.Path & "\" & "datain1.txt" For Input As #1
    For i = 1 To 20
        Input #1, Arr1(i)
    Next i
    Close #1
End Sub
' 提供给考生的程序
Sub ReadData2()
    Open App.Path & "\" & "datain2.txt" For Input As #1
    For i = 1 To 20
        Input #1, Arr2(i)
    Next i
    Close #1
End Sub
' 提供给考生的程序
Sub WriteData(Filename As String, Num As Integer)
    Open App.Path & "\" & Filename For Output As #1
    Print #1, Num
    Close #1
End Sub
查看答案
' 要求考生编写的程序
Dim Sum As Integer
' 要求考生编写的程序
Private Sub C1_Click()
    ReadData1
    ReadData2
End Sub
' 要求考生编写的程序
Private Sub C2_Click()
    Dim Arr3(20) As Integer
    Sum = 0
    For i = 1 To 20
        Arr3(i) = Int(Arr1(i) / Arr2(i))
        Sum = Sum + Arr3(i)
    Next i
    Print "Sum = "; Sum
End Sub
' 要求考生编写的程序
Private Sub C3_Click()
    WriteData "DataOut.txt", Sum
End Sub
6材料分析题6 / 10
  
查看答案
Private Sub Clea_Click()
    P1.Cls
End Sub
Private Sub Dis_Click()
    P1.Print "等级考试"
End Sub
8材料分析题8 / 10
  
  
查看答案
Private Sub Form_Click()
    If Op1 And Op3 Then
        Text1.Text = "坐飞机去广州"
    ElseIf Op1 And Op4 Then
        Text1.Text = "坐飞机去昆明"
    ElseIf Op2 And Op3 Then
        Text1.Text = "坐火车去广州"
    ElseIf Op2 And Op4 Then
        Text1.Text = "坐火车去昆明"
    End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
    Open App.Path & "\out3.txt" For Output As #1
    Print #1, Op1.Value, Op2.Value, Op3.Value, Op4.Value, Text1.Text
    Close #1
End Sub
9材料分析题9 / 10
  
查看答案
Dim a(5, 10) As Integer
Dim s(5)
Private Sub Command1_Click()
    Open App.Path & "\in4.txt" For Input As #1
    For i = 1 To 5
        For j = 1 To 10
            Input #1, a(i, j)
        Next j
    Next i
    Close #1
End Sub
Private Sub Command2_Click()
    For i = 1 To 5
        s(i) = 0
        For j = 1 To 10
            s(i) = a(i, j) + s(i)
        Next j
        s(i) = CInt(s(i) / 10)
        Text1(i - 1) = s(i)
    Next i
End Sub
Private Sub Command3_Click()
    For k = 1 To 5
        Shape1(k - 1).Height = s(k) * 20
        m = Line2.Y1
        Shape1(k - 1).Top = m - Shape1(k - 1).Height
        Shape1(k - 1).Visible = True
    Next k
End Sub
10材料分析题10 / 10
   
' 提供给考生的程序
Option Base 1
Dim Arr1(20) As Integer
Dim Arr2(20) As Integer
Sub ReadData1()
    Open App.Path & "\" & "datain1.txt" For Input As #1
    For i = 1 To 20
        Input #1, Arr1(i)
    Next i
    Close #1
End Sub
Sub ReadData2()
    Open App.Path & "\" & "datain2.txt" For Input As #1
    For i = 1 To 20
        Input #1, Arr2(i)
    Next i
    Close #1
End Sub
查看答案
' 需考生定义的变量
Dim Sum As Integer
Sub WriteData(Filename As String, Num As Integer)
    Open App.Path & "\" & Filename For Output As #1
    Print #1, Num
    Close #1
End Sub
Private Sub C1_Click()
    ReadData1
    ReadData2
End Sub
Private Sub C2_Click()
    Dim Arr3(20) As Integer
    Sum = 0
    For i = 1 To 20
        Arr3(i) = Int(Arr1(i) / Arr2(i))
        Sum = Sum + Arr3(i)
    Next i
    Print "Sum = "; Sum
End Sub
Private Sub C3_Click()
    WriteData "DataOut.txt", Sum
End Sub
← 上一卷下一卷 →