How many items in a listbox?

jumpjack

New member
Local time
Today, 13:28
Joined
Jun 22, 2012
Messages
2
I found a cool code to perform drag&drop among two listboxes:

Code:
Private Sub ListBox2_BeforeDragOver(ByVal Cancel As _
                            MSForms.ReturnBoolean, ByVal Data As _
                            MSForms.DataObject, ByVal X As Single, _
                            ByVal Y As Single, ByVal DragState As Long, _
                            ByVal Effect As MSForms.ReturnEffect, _
                            ByVal Shift As Integer)
    Cancel = True
    Effect = 1
End Sub Private Sub ListBox2_BeforeDropOrPaste(ByVal _
                                Cancel As MSForms.ReturnBoolean, _
                                ByVal Action As Long, ByVal Data As _
                                MSForms.DataObject, ByVal X As Single, _
                                ByVal Y As Single, ByVal Effect As _
                                MSForms.ReturnEffect, ByVal Shift As Integer)
    Cancel = True
    Effect = 1
    ListBox2.AddItem Data.GetText
End Sub
  
 'this starts the drag and drop from ListBox1
Private Sub ListBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    
    Dim MyDataObject As DataObject 'data object stores the data being dragged
    If Button = 1 Then 'left ouse button
        Set MyDataObject = New DataObject
        Dim Effect As Integer
        MyDataObject.SetText ListBox1.Value 'set the text of the object being dragged
        Effect = MyDataObject.StartDrag
    End If
End Sub
  
 Private Sub UserForm_Initialize()
    For i = 1 To 10
        ListBox1.AddItem "Choice " _
            & (ListBox1.ListCount + 1)
    Next i
End Sub

Now I ask: how many items can a listbox contain in Excel 2007? I know Excel 2007 limits have been raised a lot w.r.t. previous versions, for what concerns sheets contents, but what about listbox contents?
 
You may get more responses if you told us in plain English what you are trying to do.
Having a list box with the maximum number of entries does not seem to be an optimum strategy for anything.

More info on the real need and environment is needed to get you more meaningful responses.

There is a listbox video tutorial at
http://www.datapigtechnologies.com/flashfiles/listboxtrick.html
It isn't drag and drop, but has interesting and useful concepts.
 
my customer asked to me to implement a drag&drop mechanism among tables containing up to 1 million entries...
But actually it's a nonsense such a long listbox, i'll use it just as a container for filter results, I think it's better!
 

Users who are viewing this thread

Back
Top Bottom