本栏目下题库来源于互联网,轻速云承诺对于用户导入平台的题库是严格保密的,不会在此呈现!
轻速云给您提供更好的在线考试系统服务!
二级VB上机题库29
1、【 简答题
    
Private Sub Command1_Click()
    Dim n As Integer
    Cls
'    ? = InputBox("请输入一个整数")
    n = InputBox("请输入一个整数")
    Print "因子数="; fun(n)
End Sub
Function fun(m As Integer)
    Dim s As Integer
    s = 0
    For k = 1 To Abs(m) / 2
'        If m Mod k = ? Then
        If m Mod k = 0 Then
            s = s + 1
            Print k
        End If
    Next k
'    ?
    fun = s
End Function [10分]
解析:
' n
' 0
' fun = s
2、【 简答题
    [10分]
解析:
  按要求解答即可
3、【 简答题
    
Private Function IsPrime(ByVal x As Integer) As Boolean
    Dim i As Integer
    For i = 2 To Sqr(x)
        If x Mod i = 0 Then
            IsPrime = False
            Exit Function
        End If
    Next
    IsPrime = True
End Function
Private Sub Command1_Click()
'考生编写程序开始
'======================================
????
'=========================================
'考生编写程序结束
    Open App.Path & "\out5.dat" For Output As #1
    Print #1, Text1.Text, Label1.Caption, Label2.Caption
    Close #1
End Sub [10分]
解析:
    Dim i As Integer
    Dim n As Integer
   
    n = Val(Text1.Text)
    If n Mod 2 <> 0 Then
        MsgBox "请输入偶数!"
        Exit Sub
    End If
    For i = 3 To n / 2
        If IsPrime(i) And IsPrime(n - i) Then
            Label1.Caption = i
            Label2.Caption = n - i
            Exit For
        End If
    Next
4、【 简答题
    [10分]
解析:
  按要求解答即可
5、【 简答题
    
Private Sub Command1_Click()
    Dim st$, ch$
    Open App.Path & "\in3.txt" For Input As #1
    Do While Not EOF(1)
        Input #1, ch
'        st = ? & ch
    Loop
    Close #1
    Text1 = st
End Sub
Private Sub Command2_Click()
    Dim st$, word$, c$
    st = Text1
    n = Len(st)
    For k = 1 To n
'        ? = Mid(st, k, 1)
        If c <> " " Then
            word = word & c
        Else
            List1.AddItem word
'            ? = ""
        End If
    Next
    List1.AddItem word
End Sub [10分]
解析:
        st = st & ch
        c = Mid(st, k, 1)
            word = ""
6、【 简答题
    
Dim stepy As Integer    '纵向移动增量
Dim stepx As Integer    '横向移动增量
Const LEFT_BUTTON = 1
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    Dim x0 As Integer, y0 As Integer, a As Single, radius As Integer
    radius = Shape1.Width / 2              '圆的半径
    If Button = LEFT_BUTTON Then
        x0 = Shape1.Left + radius          '圆心的x坐标
        y0 = Shape1.Top + radius            '圆心的y坐标
        If x = x0 Then
            stepy = Sgn(y - y0) * 50
'            stepx = ?
        Else
            a = (y - y0) / (x - x0)          '斜率
            stepx = Sgn(x - x0) * 50
'            ? = a * stepx
            If Abs(stepy) > Abs(stepx) Then
                stepy = Sgn(y - y0) * 50
                stepx = stepy / a
            End If
        End If
'        ? = True
    Else
'        ? = False
    End If
End Sub
Private Sub Timer1_Timer()
'    Shape1.Move Shape1.Left + stepx, Shape1.Top + ?
End Sub [10分]
解析:
Dim stepy As Integer    '纵向移动增量
Dim stepx As Integer    '横向移动增量
Const LEFT_BUTTON = 1
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    Dim x0 As Integer, y0 As Integer, a As Single, radius As Integer
    radius = Shape1.Width / 2              '圆的半径
    If Button = LEFT_BUTTON Then
        x0 = Shape1.Left + radius          '圆心的x坐标
        y0 = Shape1.Top + radius            '圆心的y坐标
        If x = x0 Then
            stepy = Sgn(y - y0) * 50
            stepx = 0
        Else
            a = (y - y0) / (x - x0)          '斜率
            stepx = Sgn(x - x0) * 50
            stepy = a * stepx
            If Abs(stepy) > Abs(stepx) Then
                stepy = Sgn(y - y0) * 50
                stepx = stepy / a
            End If
        End If
        Timer1.Enabled = True
    Else
        Timer1.Enabled = False
    End If
End Sub
Private Sub Timer1_Timer()
    Shape1.Move Shape1.Left + stepx, Shape1.Top + stepy
End Sub
7、【 简答题
    [10分]
解析:
Private Sub Command1_Click()
    Text1.PasswordChar = ""
End Sub
Private Sub Command2_Click()
    Text1.PasswordChar = "*"
End Sub
Private Sub Command3_Click()
    Text1 = ""
    Text1.SetFocus
End Sub
8、【 简答题
    
Private Sub Command1_Click()
    Dim k%
'    For k = List1.ListCount - 1 To 0 ?
        If List1.Selected(k) = True Then
'            List2.AddItem ?
'            List1.RemoveItem ?
        End If
    Next k
End Sub
Private Sub Command2_Click()
    Dim k%
    Text1 = "已经选中的城市有:"
    For k = 0 To List2.ListCount - 1 Step 1
'        Text1 = ? & " " & List2.List(k)
    Next k
End Sub [10分]
解析:
    For k = List1.ListCount - 1 To 0 Step -1
            List2.AddItem List1.List(k)
            List1.RemoveItem k
        Text1 = Text1 & " " & List2.List(k)
9、【 简答题
    
Private Sub C1_Click()
    Timer1.Enabled = ?
End Sub
Private Sub C2_Click()
    ? = False
End Sub
Private Sub Timer1_Timer()
    P1.Move P1.Left + ?
End Sub [10分]
解析:
Private Sub C1_Click()
    Timer1.Enabled = True
End Sub
Private Sub C2_Click()
    Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
    P1.Move P1.Left + 20
End Sub
10、【 简答题
    [10分]
解析:
Private Sub Command1_Click()
    Text2.Text = Form1.Text1.SelLength
End Sub
1
1页,共10个题库
1页,共10个题库
轻速云给您提供更好的在线考试系统服务!
推荐
推荐题库
众多企事业单位的信赖之选
36万+企事业单位的共同选择
查看更多合作案例
众多企事业单位的信赖之选
开始使用轻速云组织培训考试
四步组织一场考试答题,一键搭建企业培训平台
免费使用 免费使用 预约演示
咨询热线
400-886-8169
周一到周日 8:00-22:00
©2023 轻速云 苏ICP备16049646号-1 轻速云科技提供专业的在线考试系统、在线培训系统
联系我们
客服热线客服热线:400-886-8169 | 周一至周日 8:00-22:00
©2023 轻速云 苏ICP备16049646号-1
轻速云科技提供专业的在线考试系统、在线培训系统
在线咨询 400-886-8169