'************************************** ' Name: Drag ListBox Item ' Description:Move items within a ListBo ' x by dragging them. ' By: John Korejwa ' ' ' Inputs:None ' ' Returns:None ' 'Assumes:None ' 'Side Effects:None '************************************** 'Paste code into form with a listbox nam ' ed List1. Private m_DragItem As Long Private Sub Form_Load() List1.AddItem "Earth" List1.AddItem "Juptiter" List1.AddItem "Mars" List1.AddItem "Mercury" List1.AddItem "Neptune" List1.AddItem "Saturn" List1.AddItem "Uranus" List1.AddItem "Venus" End Sub Private Sub List1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) m_DragItem = List1.ListIndex End Sub Private Sub List1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) Dim d As Long, s As String If ((Button = 1) And (m_DragItem <> List1.ListIndex)) Then s = List1.List(m_DragItem) d = List1.ItemData(m_DragItem) While (m_DragItem > List1.ListIndex) List1.List(m_DragItem) = List1.List(m_DragItem - 1) List1.ItemData(m_DragItem) = List1.ItemData(m_DragItem - 1) m_DragItem = m_DragItem - 1 Wend While (m_DragItem < List1.ListIndex) List1.List(m_DragItem) = List1.List(m_DragItem + 1) List1.ItemData(m_DragItem) = List1.ItemData(m_DragItem + 1) m_DragItem = m_DragItem + 1 Wend List1.List(m_DragItem) = s List1.ItemData(m_DragItem) = d End If End Sub