计算机类二级VB

二级VB上机题库34

10 题含答案VB
共 10 题返回本类
2材料分析题2 / 10
  
查看答案
Private Sub Form_Load()
    Timer1.Enabled = True
'或    Timer1 = True
End Sub
Private Sub Timer1_Timer()
    Shape1.Top = Shape1.Top + 100
'或    Shape1.Top = 100 + Shape1.Top
'或    Shape1.Move Shape1.Left, 100 + Shape1.Top
'或    Shape1.Move Shape1.Left, Shape1.Top + 100
End Sub
3材料分析题3 / 10
   
Private Sub Text2_Change()
    'If ? = 1 Then
    '    Form1.Text3.PasswordChar = ?
    Else
    '    Text3.PasswordChar = ?
    End If
    'Text3.Text = ?
End Sub
查看答案
    If Check1.Value = 1 Then
        Form1.Text3.PasswordChar = ""
        Text3.PasswordChar = "#"
    Text3.Text = Text2.Text
4材料分析题4 / 10
   
Private Sub Command1_Click()
    Dim x As Integer, k As Integer
    x = Val(Text1(1).Text)
    'For k = 2 To ?
      'x = FindMin(Val(Text1(k).Text), ?)
    Next
    'lblResult.Caption = ?
End Sub
Public Function FindMin(x As Integer, y As Integer)
    'If x ? y Then
        FindMin = y
    Else
        FindMin = x
    End If
End Function
查看答案
    For k = 2 To 5
      x = FindMin(Val(Text1(k).Text), x)
    lblResult.Caption = x
    If x > y Then
5材料分析题5 / 10
   
Private arr(100) As Integer
Private n As Integer
Private Sub Command2_Click()
    Open App.Path & "\out5.txt" For Output As #1
    Print #1, Text1.Text
    Print #1, Text2.Text
    Print #1, Text3.Text
    Print #1, Text4.Text
    Close #1
    MsgBox "保存成功!"
End Sub
Private Sub Form_Load()
    Open App.Path & "\in5.txt" For Input As #1
    n = 0
    Do While Not EOF(1)
        Input #1, x
        n = n + 1
        arr(n) = x
    Loop
    Close #1
End Sub
Private Sub Command1_Click()
'========考生编写程序开始========
???
'==========考生编写程序结束==============
End Sub
查看答案
    Text1.Text = n
    Sum = 0
    count1 = 0
    count2 = 0
    For i = 1 To n
        Sum = Sum + arr(i)
        If arr(i) < 60 Then
          count1 = count1 + 1
        Else
          count2 = count2 + 1
        End If
        Avg = Sum / n
    Next
    Text2.Text = Int(Avg + 0.5)
    Text3.Text = count1
    Text4.Text = count2
8材料分析题8 / 10
   
Dim a(10) As Integer
Private Sub Command1_Click()
    x = a(1)
    y = a(1)
    For i = 1 To 10
        If Option1.Value = True Then
'            If a(i) ?  x Then
'                ?= a(i)
            End If
'        ElseIf a(i) ? Then
'            ?= a(i)
        End If
    Next
    If Option1.Value = True Then
        Label2.Caption = x
    Else
        Label2.Caption = y
    End If
End Sub
Private Sub Form_Load()
    For i = 1 To 10
        a(i) = Int(Rnd * 100)
    Next
End Sub
查看答案
'            If a(i) > x Then或            If a(i) >= x Then
                x = a(i)
'        ElseIf a(i) <= y Then或        ElseIf a(i) < y Then
            y = a(i)
9材料分析题9 / 10
   
Private Sub Command1_Click()
    Call MoveAll
End Sub
Public Sub MoveItem(L1 As ListBox, L2 As ListBox)
'    L2.AddItem ?
'    L2.AddItem L1.Text
    L2.AddItem L1.List(L1.ListIndex)
'    L1.RemoveItem ?
    L1.RemoveItem L1.ListIndex
End Sub
Public Sub MoveAll()
'  For i = 0 To  ?
  For i = 0 To List1.ListCount - 1
        List2.AddItem List1.List(i)
  Next
End Sub
Private Sub List1_DblClick()
'    Call MoveItem(?)
    Call MoveItem(List1, List2)
End Sub
查看答案
'L1.Text  或 L1.List(L1.ListIndex)
'L1.ListIndex
'List1.ListCount - 1 或 9
'List1, List2
10材料分析题10 / 10
   
Dim a(7, 7) As Integer
Private Sub Form_Load()
    read
End Sub
Public Sub read()
    Open App.Path & "\Data5.txt" For Input As #1
    Do While Not EOF(1)
        For i = 1 To 7
            For j = 1 To 7
                Input #1, a(i, j)
            Next j
        Next i
    Loop
    Close #1
End Sub
Public Sub Save()
    Open App.Path & "\out5.txt" For Output As #1
    Print #1, lblFirst.Caption, lblSecond.Caption
  Close #1
End Sub
Private Sub Command1_Click()
    Dim Sum As Long
    N = 7
    Counter = 0
    Sum = 0
'===============考生编写程序开始======================
???
    '===============考生编写程序结束======================
    Save
End Sub
查看答案
    For k = 1 To N
        Sum = Sum + a(k, k)
        If a(k, k) / 3 = Int(a(k, k) / 3) Then
            Counter = Counter + 1
        End If
        If k <> N - k + 1 Then
            If a(k, N - k + 1) / 3 = Int(a(k, N - k + 1) / 3) Then
                Counter = Counter + 1
            End If
        End If
    Next
    lblSecond.Caption = Sum
    lblFirst.Caption = Counter
← 上一卷下一卷 →