计算机类二级VB

二级VB上机题库15

10 题含答案VB
共 10 题返回本类
1材料分析题1 / 10
  
查看答案
Private Sub Command1_Click()
    Label1.Visible = 0
    Text1.Visible = 0
    Print Text1.Text
End Sub
3材料分析题3 / 10
  
查看答案
Private Sub Add_Click()
        Text1.Text = InputBox("请输入要添加的项目")
        'List1.AddItem ?
        List1.AddItem Text1.Text
End Sub
Private Sub Delete_Click()
    Text1.Text = InputBox("请输入要删除的项目")
    'For i = 0 To ?
    For i = 0 To List1.ListCount - 1
        'If List1.List(i) = ? Then
        If List1.List(i) = Text1.Text Then
            'List1.RemoveItem ?
            List1.RemoveItem i
        End If
    Next i
End Sub
4材料分析题4 / 10
   
Option Base 1
Private Sub Sort(a() As Integer)
    Dim Start As Integer, Finish As Integer
    Dim i As Integer, j As Integer, t As Integer
    'Start = ?(a)
    'Finish = ?(a)
    'For i = ? To 2 Step -1
        'For j = 1 To ?
            'If a(j) ? a(j + 1) Then
                t = a(j + 1)
                a(j + 1) = a(j)
                a(j) = t
            End If
        Next j
    Next i
End Sub
Private Sub Command1_Click()
    Dim arr1
    Dim arr2(4) As Integer
    arr1 = Array(Val(Text1.Text), Val(Text2.Text), Val(Text3.Text), Val(Text4.Text))
    For i = 1 To 4
        arr2(i) = CInt(arr1(i))
    Next i
    Sort arr2()
    Text1.Text = arr2(1)
    Text2.Text = arr2(2)
    Text3.Text = arr2(3)
    Text4.Text = arr2(4)
End Sub
查看答案
Option Base 1
Private Sub Sort(a() As Integer)
    Dim Start As Integer, Finish As Integer
    Dim i As Integer, j As Integer, t As Integer
    Start = LBound(a)
    Finish = UBound(a)
    For i = UBound(a) To 2 Step -1
        For j = 1 To i - 1
            If a(j) > a(j + 1) Then
                t = a(j + 1)
                a(j + 1) = a(j)
                a(j) = t
            End If
        Next j
    Next i
End Sub
Private Sub Command1_Click()
    Dim arr1
    Dim arr2(4) As Integer
    arr1 = Array(Val(Text1.Text), Val(Text2.Text), Val(Text3.Text), Val(Text4.Text))
    For i = 1 To 4
        arr2(i) = CInt(arr1(i))
    Next i
    Sort arr2()
    Text1.Text = arr2(1)
    Text2.Text = arr2(2)
    Text3.Text = arr2(3)
    Text4.Text = arr2(4)
End Sub
5材料分析题5 / 10
   
' 提供给考生的程序
Option Base 1
Dim Arr(100) As Integer
' 提供给考生的程序
Sub ReadData()
    Open App.Path & "\" & "datain1.txt" For Input As #1
        For i = 1 To 100
        Input #1, Arr(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 Read_Click()
    ReadData
End Sub
' 要求考生编写的程序
Private Sub Calc_Click()
    Dim S As String
    Sum = 0
    For i = 1 To 100
        If Arr(i) >= 50 Then
            Sum = Sum + Arr(i)
            S = S & Str(Arr(i)) & "  "
        End If
    Next i
    Text1.Text = S
    Print "Sum = "; Sum
End Sub
' 要求考生编写的程序
Private Sub Save_Click()
    WriteData "DataOut.txt", Sum
End Sub
6材料分析题6 / 10
  
查看答案
Private Sub Command1_Click()
    Label1.Visible = True
    Label1.Caption = Text1.Text
    Text1.Visible = False
End Sub
7材料分析题7 / 10
  
查看答案
Private Sub HScroll1_Change()
    Text1.Width = HScroll1.Value * 1.2
    Text1.Height = Me.HScroll1.Value
End Sub
8材料分析题8 / 10
   
Private Sub Form_Click()
    If Option1.Value = True Then
        Text1.Text = InputBox("请输入要添加的项目")
        'List1.AddItem ?
    End If
    If Option2.Value = True Then
        Text1.Text = InputBox("请输入要删除的项目")
        'For i = 0 To ?
            'If List1.List(i) = ? Then
                'List1.RemoveItem ?
            End If
        Next i
    End If
End Sub
查看答案
Private Sub Form_Click()
    If Option1.Value = True Then
        Text1.Text = InputBox("请输入要添加的项目")
        List1.AddItem Text1.Text
    End If
    If Option2.Value = True Then
        Text1.Text = InputBox("请输入要删除的项目")
        For i = 0 To List1.ListCount - 1
            If List1.List(i) = Text1.Text Then
                List1.RemoveItem i
            End If
        Next i
    End If
End Sub
9材料分析题9 / 10
   
Option Base 1
Private Sub Sort(a() As Integer)
    Dim Start As Integer, Finish As Integer
    Dim i As Integer, j As Integer, t As Integer
    'Start = ?(a)
    'Finish = ?(a)
    'For i = ? To 2 Step -1
        'For j = 1 To ?
            'If a(j) ? a(j + 1) Then
                t = a(j + 1)
                a(j + 1) = a(j)
                a(j) = t
            End If
        Next j
    Next i
End Sub
Private Sub Command1_Click()
    Dim arr1
    Dim arr2(4) As Integer
    arr1 = Array(Val(Text1.Text), Val(Text2.Text), Val(Text3.Text), Val(Text4.Text))
    For i = 1 To 4
        arr2(i) = CInt(arr1(i))
    Next i
    Sort arr2()
    Text1.Text = arr2(1)
    Text2.Text = arr2(2)
    Text3.Text = arr2(3)
    Text4.Text = arr2(4)
End Sub
查看答案
Option Base 1
Private Sub Sort(a() As Integer)
    Dim Start As Integer, Finish As Integer
    Dim i As Integer, j As Integer, t As Integer
    Start = LBound(a)
    Finish = UBound(a)
    For i = Finish To 2 Step -1
        For j = 1 To i - 1
            If a(j) < a(j + 1) Then
                t = a(j + 1)
                a(j + 1) = a(j)
                a(j) = t
            End If
        Next j
    Next i
End Sub
Private Sub Command1_Click()
    Dim arr1
    Dim arr2(4) As Integer
    arr1 = Array(Val(Text1.Text), Val(Text2.Text), Val(Text3.Text), Val(Text4.Text))
    For i = 1 To 4
        arr2(i) = CInt(arr1(i))
    Next i
    Sort arr2()
    Text1.Text = arr2(1)
    Text2.Text = arr2(2)
    Text3.Text = arr2(3)
    Text4.Text = arr2(4)
End Sub
10材料分析题10 / 10
   
' 提供给考生的程序
Option Base 1
Dim Arr(100) As Integer
' 提供给考生的程序
Sub ReadData()
    Open App.Path & "\" & "datain1.txt" For Input As #1
        For i = 1 To 100
        Input #1, Arr(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 Read_Click()
    ReadData
End Sub
' 要求考生编写的程序
Private Sub Calc_Click()
    Dim S As String
    Sum = 0
    For i = 1 To 100
        If Arr(i) < 50 Then
            Sum = Sum + Arr(i)
            S = S & Str(Arr(i)) & "  "
        End If
    Next i
    Text1.Text = S
    Print "Sum = "; Sum
End Sub
' 要求考生编写的程序
Private Sub Save_Click()
    WriteData "DataOut.txt", Sum
End Sub
← 上一卷下一卷 →