题库 题库

【简答题】

 
Private Sub Form_KeyDown(KeyCode As Integer, _Shift As Integer)
    If Chr(KeyCode) = "A" Then
        Text1.Text = InputBox("请输入要添加的项目")
        'List1.AddItem ?
    End If
        If Chr(KeyCode) = "D" 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_KeyDown(KeyCode As Integer, _Shift As Integer)
    If Chr(KeyCode) = "A" Then
        Text1.Text = InputBox("请输入要添加的项目")
        List1.AddItem Text1.Text
    End If
        If Chr(KeyCode) = "D" 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

相关试题