To change the item’s location by dragging the mouse in a listbox, follow this tip:
Sub List1_MouseDown (Button As _ Integer, Shift As Integer, X As _ Single, Y As Single) Old_Index = List1.ListIndex TmpText = List1.TextEnd Sub
While the button mouse is on, this event saves the current indexand text to variables:
Sub List1_MouseUp (Button As Integer,_ Shift As Integer, X As Single, _ Y As Single) New_Index = List1.ListIndex If Old_Index <> New_Index Then List1.RemoveItem Old_Index List1.AddItem TmpText, New_Index End IfEnd Sub
When the button mouse is off, a new variable sets the new mouselocation. To test if it is the same, remove the old item and addthe new item with the text saved in TmpText.
General Declarations:
Dim TmpText As StringDim Old_Index As IntegerDim New_Index As Integer