1

我只是想问是否有人知道为什么Object reference not set to an instance of an object当我尝试在我正在尝试制作的媒体播放器上填写播放列表功能的列表框时我可能会收到错误消息。

Public Class PlaylistsForm

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        ListBox1.Items.Clear()
        For Each Item As String In My.Settings.Playlist1
            ListBox1.Items.Add(Item)
        Next
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        Dim pl2 As New Setting(My.Settings.Playlist2)
        ListBox1.Items.Clear()
        For Each Item As String In My.Settings.Playlist2
            ListBox1.Items.Clear()
            ListBox1.Items.Add(Item)
        Next
    End Sub

    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        ListBox1.Items.Clear()
        For Each Item As String In My.Settings.Playlist3
            ListBox1.Items.Clear()
            ListBox1.Items.Add(Item)
        Next
    End Sub

    Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
        ListBox1.Items.Clear()
        For Each Item As String In My.Settings.Playlist4
            ListBox1.Items.Clear()
            ListBox1.Items.Add(Item)
        Next
    End Sub

    Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
        ListBox1.Items.Clear()
        For Each Item As String In My.Settings.Playlist5
            ListBox1.Items.Clear()
            ListBox1.Items.Add(Item)
        Next
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
        ListBox1.SelectedItems.Clear()
    End Sub
End Class

抱歉 - 这里发生错误:(错误是“对象引用未设置为对象的实例”)

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        ListBox1.Items.Clear()
        For Each Item As String In My.Settings.Playlist1
            ListBox1.Items.Add(Item)
        Next
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        Dim pl2 As New Setting(My.Settings.Playlist2)
        ListBox1.Items.Clear()
        For Each Item As String In My.Settings.Playlist2
            ListBox1.Items.Clear()
            ListBox1.Items.Add(Item)
        Next
    End Sub

    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        ListBox1.Items.Clear()
        For Each Item As String In My.Settings.Playlist3
            ListBox1.Items.Clear()
            ListBox1.Items.Add(Item)
        Next
    End Sub

    Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
        ListBox1.Items.Clear()
        For Each Item As String In My.Settings.Playlist4
            ListBox1.Items.Clear()
            ListBox1.Items.Add(Item)
        Next
    End Sub

    Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged
        ListBox1.Items.Clear()
        For Each Item As String In My.Settings.Playlist5
            ListBox1.Items.Clear()
            ListBox1.Items.Add(Item)
        Next
    End Sub
4

0 回答 0