计算机类二级VB

二级VB上机题库24

10 题含答案VB
共 10 题返回本类
3材料分析题3 / 10
   
Dim s As Integer, h As Long
Private Sub Form_Load()
' Timer1.Enabled = ?
  s = -40
End Sub
Private Sub Timer1_Timer()
  Shape1.Move Shape1.Left, Shape1.Top + s
'  If Shape1.Top = ? Then
    s = -s
  End If
'  If Shape1.Top + ? = Line2.Y1 Then
    s = -s
  End If
End Sub
查看答案
'True
'Line1.Y1
'Shape1.Height
4材料分析题4 / 10
   
Dim a(100) As Integer
Private Sub Command1_Click()
    Dim k As Integer
    Open App.Path & "\in4.dat" For Input As #1
    For k = 1 To 100
        Input #1, a(k)
    Next k
    Close #1
End Sub
Private Sub Command2_Click()
'考生编写
  ???
Private Sub Form_Unload(Cancel As Integer)
    Open App.Path & "\out4.dat" For Output As #1
    Print #1, Combo1.Text; Text1.Text
    Close #1
End Sub
Function even()
    Dim s As Single, n As Integer
    s = 0
    For k = 1 To 100
        If a(k) / 2 = Fix(a(k) / 2) Then
          s = s + a(k)
          n = n + 1
        End If
    Next
    s = s / n
    even = CInt(s)
End Function
Function odd()
    Dim s As Single, n As Integer
    s = 0
    For k = 1 To 100
        If a(k) / 2 <> Fix(a(k) / 2) Then
          s = s + a(k)
          n = n + 1
        End If
    Next
    s = s / n
    odd = CInt(s)
End Function
Function all()
    Dim s As Single, n As Integer
    s = 0
    For k = 1 To 100
      s = s + a(k)
    Next
    s = s / 100
    all = CInt(s)
End Function
查看答案
    Select Case Combo1.ListIndex
        Case 0
            Text1 = even()
        Case 1
            Text1 = odd()
        Case 2
            Text1 = all()
    End Select
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
    For i = 1 To N
        For j = 1 To M
            t = Mat(i, 2)
            Mat(i, 2) = Mat(i, 4)
'            ?
        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
    For i = 1 To N
        For j = 1 To M
            t = Mat(i, 2)
            Mat(i, 2) = Mat(i, 4)
            Mat%(i, 4) = 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
7材料分析题7 / 10
  
查看答案
Private Sub Cmd1_Click()
  Line4.Visible = True
End Sub
Private Sub Cmd2_Click()
  Line4.Visible = False
End Sub
8材料分析题8 / 10
   
Private Sub C1_Click(Index As Integer)
    Select Case Index
        Case ?
            Timer1.Enabled = False
        Case 0
            Timer1.Enabled = ?
    End Select
End Sub
Private Sub Timer1_Timer()
    Text1.Text = ?
End Sub
查看答案
Private Sub C1_Click(Index As Integer)
    Select Case Index
        Case 1
            Timer1.Enabled = False
        Case 0
            Timer1.Enabled = True
    End Select
End Sub
Private Sub Timer1_Timer()
    Text1.Text = Text1.Text + 1
End Sub
9材料分析题9 / 10
   
Dim s As Integer
Private Sub Command1_Click()
s = Val(InputBox("输入里程数(单位:公里)"))
End Sub
Private Sub Command2_Click()
  If s > 0 Then
    'Select Case  ?
      Case Is <= 4
        '?
      Case Is <= 15
        ' f = 10 + ?
      '?
        ' f = 10 + ? + (s - 15) * 1.8
    End Select
    Text1.Text = f
  Else
    MsgBox "请单击“输入”按钮输入里程数!"
  End If
End Sub
查看答案
Dim s As Integer
Private Sub Command1_Click()
s = Val(InputBox("输入里程数(单位:公里)"))
End Sub
Private Sub Command2_Click()
  If s > 0 Then
    Select Case s
      Case Is <= 4
        f = 10
      Case Is <= 15
        f = 10 + (s - 4) * 1.2
      Case Else
        f = 10 + (15 - 4) * 1.2 + (s - 15) * 1.8
    End Select
    Text1.Text = f
  Else
    MsgBox "请单击“输入”按钮输入里程数!"
  End If
End Sub
10材料分析题10 / 10
   
Option Base 1
Dim s As String
Private Sub Command1_Click()
    Open App.Path & "\in5.dat" For Input As #1
    s = Input(LOF(1), #1)
    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, Text1.Text, Text2.Text
    Close #1
End Sub
查看答案
  Dim a(26) As Integer
  n = Len(s)
  For i = 1 To n
      c = UCase(Mid(s, i, 1))
      If c >= "A" And c <= "Z" Then
        j = Asc(c) - Asc("A") + 1
        a(j) = a(j) + 1
      End If
  Next i
  Max = a(1)
  t = Chr(Asc("A"))
  For i = 2 To 26
      If a(i) > Max Then
        Max = a(i)
        t = Chr(Asc("A") + i - 1)
      End If
  Next i
  Text1.Text = t
  Text2.Text = Max
← 上一卷下一卷 →