Using Visual Basic 6.0, I'm trying to populate one listbox with another listbox's items.
Can anyone please explain why the following sub fails to work properly, getting a Type mismatch when passing two listboxes as parameters.
Public Sub copyListboxes(Byref lstFrom as Listbox, Byref lstTo as Listbox)
Dim i as integer
For i = 0 to lstFrom.Listcount -1
lstTo.Additem lstFrom.List(i)
Next i
End Sub
'Call copyListboxes(Listbox1,Listbox2) 'Type Mismatch ... ?
Thanks in advance.
I was able to reproduce your error by using Comboxes instead of Listboxes:
To solve this you can either use Listbox controls or change your sub to work with Combobox controls: