i am having trouble linking 2 listboxes together... What i woud like to happen is a selecting from listbox1 to populate listbox2. Any ideas on what to do?

thanks in advance

Maybe this small example gives you an idea:

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
		For i As Integer = 1 To 10
			ListBox1.Items.Add("Value " & i)
		Next
	End Sub

	Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
		ListBox2.Items.Clear()
		For i As Integer = 40 To 50
			ListBox2.Items.Add(ListBox1.SelectedItem.ToString & " => " & New String(Chr(i), 5))
		Next
	End Sub

See if this helps.:)

Public Class Form1
    Private arCmbItems() As String = {"item 1", "item 2", "item etc.", "item.Else"}

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        With ListBox1
            .Items.AddRange(arCmbItems) '// add items to ListBox from String.Array.
        End With
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        With ListBox2.Items
            If Not ListBox1.SelectedIndex = -1 Then '// check if item is selected since Index.of -1 is No.Item.Selected.
                .Clear() '// .Clear for new input.
                Select Case ListBox1.SelectedItem '// check value selected.
                    Case arCmbItems(0) '// case 1st.item.
                        .Add("1a") : .Add("1b") : .Add("1c")
                    Case arCmbItems(2) '// case 3rd.item.
                        .Add("etc.a") : .Add("etc.b") : .Add("etc.c")
                    Case arCmbItems(1) '// case 2nd.item.
                        .Add("2a") : .Add("2b") : .Add("2c")
                    Case Else '// if any other item selected.
                        .Add("No items")
                        .Add("in String.Array")
                        .Add("for this .SelectedItem")
                End Select
            End If
        End With
    End Sub
End Class

thank you. The code helped a lot

>>The code helped a lot
The "code" seems to help quite a bit more than a lot.
Glad I could help.:)
code.order

Hi...I have this assignment wherein the user will input 100 names in inputbox then display the first ten(10) names in the list box...I dont know how to apply the array and loops in it..I find it so hard..I need your help everyone..I wish someone could.

april_004, start your own thread and send me a link via a p.m.; will see what I can do Then.
ng5, my.apologies for this post.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.