0

Hello everyone. Thanks in advance for checking out my thread. I am trying to make a simple program in vb that includes a combobox with a textbox on top and a list box.

Basically, the user should be able to type somthing in the textbox, click a button which adds it to the combobox, then click another button which adds it to the listbox. I have all of this done fine, but i am running into some trouble and have some questions.

First, theres a textbox right ontop of my combo box. I would like the textbox text to display whatever value is selected in the combobox. right now its just always blank because the textbox is on top.

Next, if the item from the combobox is added to the listbox, you should not be able to delete it from the combo box. how would i achieve this?

Finally, i need to create a function named "is included" that searches the listbox to check if a certain value is included in the list box. This search just needs to return true or false. I have no idea where to start with this part or what i should do. any help is appreciated. this is what i have...very simple i know.

Public Class ItunesKiller

    Private Sub AddButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddButton.Click
        For Each line As String In SongTextBox.Lines

            SongComboBox.Items.Add(line)

        Next
    End Sub

    Private Sub DeleteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteButton.Click
        SongComboBox.Items.Remove(SongComboBox.SelectedItem)

    End Sub

    Private Sub IncludeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IncludeButton.Click
        PlayListBox.Items.Add(SongComboBox.SelectedItem)
    End Sub

    Private Sub RemoveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveButton.Click
        PlayListBox.Items.Remove(PlayListBox.SelectedItem)
    End Sub

    Private Function IsIncluded(ByVal SongName As String) As Boolean

    End Function
End Class
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Oxiegen
0

Add the parts in red.

Public Class ItunesKiller

    Private Sub AddButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddButton.Click
        For Each line As String In SongTextBox.Lines

            SongComboBox.Items.Add(line)

        Next
    End Sub

    Private Sub SongComboBox_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles SongComboBox.SelectedIndexChanged
        TextBoxOnTop.Text = SongComboBox.SelectedItem
    End Sub

    Private Sub DeleteButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteButton.Click
        If Not IsIncluded(PlayListBox.SelectedItem) Then
            SongComboBox.Items.Remove(SongComboBox.SelectedItem)
        End If
    End Sub

    Private Sub IncludeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IncludeButton.Click
        PlayListBox.Items.Add(SongComboBox.SelectedItem)
    End Sub

    Private Sub RemoveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveButton.Click
        PlayListBox.Items.Remove(PlayListBox.SelectedItem)
    End Sub

    Private Function IsIncluded(ByVal SongName As String) As Boolean
        If PlayListBox.Items.Contains(SongName) Then Return True
        Return False
    End Function
End Class
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.