计算机类二级VB

二级VB上机题库13

10 题含答案VB
共 10 题返回本类
2材料分析题2 / 10
  
查看答案
Private Sub hide_Click()
    Text1.Visible = False            '或 0
'或    Me.Text1.Visible = False      或 0
'或    Form1.Text1.Visible = False    或 0
End Sub
Private Sub show_Click()
    Text1.Visible = True            '或非0数值
'或    Me.Text1.Visible = True      或非0数值
'或    Form1.Text1.Visible = True    或非0数值
End Sub
3材料分析题3 / 10
  
查看答案
Private Sub C1_Click()
    Text1.PasswordChar = ""
'Me.Text1.PasswordChar = ""  或
'Form1.Text1.PasswordChar = "" 或
'C1.Parent.Text1.PasswordChar = ""
End Sub
Private Sub C2_Click()
    Text1.PasswordChar = "?"
'Me.Text1.PasswordChar = "?"  或
'Form1.Text1.PasswordChar = "?" 或
'C2.Parent.Text1.PasswordChar = "?"
End Sub
Private Sub C3_Click()
    C3.Parent.Text2.Text = Text1.Text
'在Text2和Text1的前面都可以加
'Me.  或
'Form1. 或
'C3.Parent.
End Sub
Private Sub Form_Load()
Text1.PasswordChar = "*"
End Sub
4材料分析题4 / 10
  
查看答案
Private Sub P1_Click()
    CD1.ShowOpen
'或 Me.CD1.ShowOpen
'或 Form1.CD1.ShowOpen
'或 P1.Parent.CD1.ShowOpen
'或 CD1.Action = 1
'或 Me.CD1.Action = 1
'或 Form1.CD1.Action = 1
'或 P1.Parent.CD1.Action = 1
End Sub
5材料分析题5 / 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()
  Dim n As Integer, t As String, word_num As Integer
  n = Len(s): t = ""
  For i = 1 To n
      c = Mid(s, i, 1)
      If c <> " " Then
        t = t + c
      Else
        If foundhuiwen(t) Then
            word_num = word_num + 1
        End If
        t = ""
      End If
  Next i
  Text1.Text = word_num
End Sub
'以下Function 过程用于判断字符串是否为回文
Function foundhuiwen(p As String)
  '考生编写
查看答案
  foundhuiwen = True
  k = Len(p)
  For i = 1 To k / 2
      If Mid(p, i, 1) <> Mid(p, k + 1 - i, 1) Then
        foundhuiwen = False
        Exit For
      End If
  Next
End Function
Private Sub Form_Unload(Cancel As Integer)
    Open App.Path & "\out5.dat" For Output As #1
    Print #1, Text1.Text
    Close #1
End Sub
6材料分析题6 / 10
  
查看答案
Private Sub Command1_Click()
    Text1.Text = InputBox("请输入身高")
    Text2.Text = InputBox("请输入体重")
End Sub
7材料分析题7 / 10
  
查看答案
Private Sub Command1_Click()
    VScroll1.Min = 100
    VScroll1.Max = 2400
    VScroll1.LargeChange = 200
    VScroll1.SmallChange = 20
End Sub
Private Sub VScroll1_Change()
    Picture1.Height = VScroll1.Value
End Sub
8材料分析题8 / 10
   
Private Sub Command1_Click()
    Text1.Text = InputBox("请输入要添加的项目")
    'List1.AddItem ?
End Sub
Private Sub Command2_Click()
    Text1.Text = InputBox("请输入要删除的项目")
    'For i = 0 To ?
        'If List1.List(i) = ? Then
        If List1.List(i) = Me.Text1.Text Then
            'List1.RemoveItem ?
        End If
    Next i
End Sub
查看答案
Private Sub Command1_Click()
    Text1.Text = InputBox("请输入要添加的项目")
    List1.AddItem Form1.Text1.Text
End Sub
Private Sub Command2_Click()
    Text1.Text = InputBox("请输入要删除的项目")
    For i = 0 To Form1.List1.ListCount - 1
        If List1.List(i) = Me.Text1.Text Then
            'List1.RemoveItem ?
            List1.RemoveItem i
        End If
    Next i
End Sub
9材料分析题9 / 10
   
Option Base 1
Private Function FindMax(a() As Integer)
    Dim Start As Integer
    Dim Finish As Integer, i As Integer
    'Start = ?(a)
    'Finish = ?(a)
    'Max = ?(Start)
    For i = Start To Finish
        'If a(i) ? Max Then Max = ?
    Next i
    FindMax = Max
End Function
Private Sub Command1_Click()
    Dim arr1
    Dim arr2(4) As Integer
    'arr1 = Array(Val(?), Val(?), Val(?), Val(?))
    For i = 1 To 4
        'arr2(i) = CInt(?)
    Next i
    'M = FindMax(?)
    Print "最大值是: "; M
End Sub
查看答案
Option Base 1
Private Function FindMax(a() As Integer)
    Dim Start As Integer
    Dim Finish As Integer, i As Integer
    Start = LBound(a)
    Finish = UBound(a)
    Max = a(Start)
    For i = Start To Finish
        If a(i) > Max Then Max = a(i)
    Next i
    FindMax = Max
End Function
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
    M = FindMax(arr2())
    Print "最大值是: "; M
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 i Mod 2 <> 0 Then
            Sum = Sum + Arr(i)
            S = S & Str(Arr(i)) & "  "
        End If
    Next i
    Form1.Text1.Text = S
    Me.Print "Sum = "; Sum
End Sub
' 要求考生编写的程序
Private Sub Save_Click()
    WriteData "DataOut.txt", Sum
End Sub
← 上一卷下一卷 →