Hello,

How to copy an item selected in a Listbox present in Form1 into a Combobox present in another form-Form2. Here the combobox contains a list of customers while the listbox contains only the selected few. For eg in the cbox i type "r" the i get a list of customers starting with letter 'r' in a listbox. Now what is the VB code to be used to copy the selected customer back to the combobox???
Thanku

you need to use add item method of combo and listindex property of listbox.

Hi,
You can use ListIndex to get the Selected Index of ListBox or ComboBox.

How to copy an item selected in a Listbox present in Form1 into a Combobox present in another form-Form2.

If ListBox1.ListIndex >= 0 Then
   Form2.ComboBox1.AddItem Form1.ListBox1.List(ListBox1.ListIndex)
End If

If you want all the item of ListBox to be copied to the Combobox

Dim i As Integer
For i = 0 To ListBox1.ListCount - 1
   Form2.ComboBox1.AddItem Form1.ListBox1.List(i)
Next
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.