计算机类二级VB

二级VB上机题库9

10 题含答案VB
共 10 题返回本类
1材料分析题1 / 10
  
查看答案
Private Sub C1_Click()
    Text1.Text = "等级考试"
End Sub
2材料分析题2 / 10
  
查看答案
Private Sub Dis_Click()
    Text1.Text = "等级考试"
End Sub
Private Sub Hid_Click()
    Text1.Visible = False
End Sub
3材料分析题3 / 10
  
  
查看答案
Private Sub C1_Click()
    If Op1 And Op3 Then
        Lab1.Caption = "坐飞机去广州"
    ElseIf Op1 And Op4 Then
        Lab1.Caption = "坐飞机去昆明"
    ElseIf Op2 And Op3 Then
        Lab1.Caption = "坐火车去广州"
    ElseIf Op2 And Op4 Then
        Lab1.Caption = "坐火车去昆明"
    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, Lab1.Caption
    Close #1
End Sub
4材料分析题4 / 10
  
查看答案
Private Sub Form_Click()
    If Op1 Then
        Text3.Text = Text1.Text
        Text1.Text = Text2.Text
        Text2.Text = Text3.Text
        Text3.Text = "交换成功"
    ElseIf Op2 Then
        Text3.Text = Text1.Text & Text2.Text
    End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
    Open App.Path & "\out4.txt" For Output As #1
    Print #1, Op1.Value, Op2.Value, Text1.Text, Text2.Text, Text3.Text
    Close #1
End Sub
5材料分析题5 / 10
   
Option Base 1
Private Sub Form_Click()
    Const N = 5
    Const M = 5
'    Dim  ?
    Dim i, j, t
'    Open App.Path & "\" & "datain.txt"  ?  As #1
    For i = 1 To N
        For j = 1 To M
'            ?
        Next j
    Next i
    Close #1
    Print
    Print "初始矩阵为:"
    Print
    For i = 1 To N
        For j = 1 To M
            Print Tab(5 * j); Mat(i, j);
        Next j
        Print
    Next i
    Print
    Print
    For i = 1 To N
        For j = 1 To M
            t = Mat(1, j)
            Mat(1, j) = Mat(3, j)
'            ?
        Next j
    Next i
    Print
    Print "交换第一行和第三行后的矩阵为:"
    Print
    For i = 1 To N
        For j = 1 To M
            Print Tab(5 * j); Mat(i, j);
        Next j
        Print
    Next i
End Sub
查看答案
Option Base 1
Private Sub Form_Click()
    Const N = 5
    Const M = 5
    Dim Mat(M, N) As Integer
    Dim i, j, t
    Open App.Path & "\" & "datain.txt" For Input As #1
    For i = 1 To N
        For j = 1 To M
            Input #1, Mat%(i, j)
        Next j
    Next i
    Close #1
    Print
    Print "初始矩阵为:"
    Print
    For i = 1 To N
        For j = 1 To M
            Print Tab(5 * j); Mat(i, j);
        Next j
        Print
    Next i
    Print
    Print
    For i = 1 To N
        For j = 1 To M
            t = Mat(1, j)
            Mat(1, j) = Mat(3, j)
            Mat%(3, j) = t
        Next j
    Next i
    Print
    Print "交换第一行和第三行后的矩阵为:"
    Print
    For i = 1 To N
        For j = 1 To M
            Print Tab(5 * j); Mat(i, j);
        Next j
        Print
    Next i
End Sub
6材料分析题6 / 10
  
查看答案
Private Sub Clea_Click()
    Text1.Text = ""
End Sub
Private Sub Dis_Click()
    Text1.Text = "等级考试"
End Sub
8材料分析题8 / 10
   
Private x As Integer
Private Sub Command1_Click()
    x = Val(InputBox("请输入正整数"))
End Sub
Private Sub Command2_Click()
    'Select Case Combo1.?
        Case 0
'        MsgBox Str(x) & ?
        Case 1
    '        MsgBox Str(x) & ?
        Case Else
            Exit Sub
    End Select
End Sub
Private Function f1(ByVal x As Integer) As String
    If x \ 2 <> x / 2 Then
        f1 = "是奇数"
    Else
        f1 = "是偶数"
    End If
End Function
'Private Function f2(ByVal x As Integer) ?
'    If x Mod 7 = ?  Then
        f2 = "能被7整除"
    Else
        f2 = "不能被7整除"
    End If
End Function
查看答案
Private x As Integer
Private Sub Command1_Click()
    x = Val(InputBox("请输入正整数"))
End Sub
Private Sub Command2_Click()
    Select Case Combo1.ListIndex
        Case 0
            MsgBox Str(x) & f1(x)
        Case 1
            MsgBox Str(x) & f2(x)
        Case Else
            Exit Sub
    End Select
End Sub
Private Function f1(ByVal x As Integer) As String
    If x \ 2 <> x / 2 Then
        f1 = "是奇数"
    Else
        f1 = "是偶数"
    End If
End Function
Private Function f2(ByVal x As Integer) As String
    If x Mod 7 = 0 Then
        f2 = "能被7整除"
    Else
        f2 = "不能被7整除"
    End If
End Function
9材料分析题9 / 10
   
'Private Flag As ?
Private Sub Form_Click()
    If Flag Then
        Shape1.Top = Shape2.Top
        Shape1.Left = Shape2.Left
        Flag = Not (Flag)
    Else
'        Shape1.Top = Shape2.Top + Shape2.Height - ?
'        Shape1.Left = Shape2.Left + Shape2.Width - ?
        Flag = Not (Flag)
    End If
End Sub
Private Sub Form_Load()
    Flag = True
End Sub
查看答案

Private Flag As Boolean
Private Sub Form_Click()
    If Flag Then
        Shape1.Top = Shape2.Top
        Shape1.Left = Shape2.Left
        Flag = Not (Flag)
    Else
        Shape1.Top = Shape2.Top + Shape2.Height - Shape1.Height
        Shape1.Left = Shape2.Left + Shape2.Width - Shape1.Width
        Flag = Not (Flag)
    End If
End Sub
Private Sub Form_Load()
    Flag = True
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
' 提供给考生的程序
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) / 10) * Int(Arr2(i) / 10)
        Sum = Sum + Arr3(i)
    Next i
    Print "Sum = "; Sum
End Sub
' 要求考生编写的程序
Private Sub C3_Click()
    WriteData "DataOut.txt", Sum
End Sub
← 上一卷下一卷 →