Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

MoveListboxItem - Move an item of a ListBox to another position

Total Hit ( 1725)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Click here to copy the following block
' Move an item of a listbox to another index
'
' If FROMINDEX = -1 then it moves the current highlighted item

Sub MoveListboxItem(ctrl As ListBox, ByVal FromIndex As Long, _
  ByVal ToIndex As Long)
  Dim sText As String, lItemData As Long
  
  ' provide a default
  If FromIndex < 0 Then FromIndex = ctrl.ListIndex
  ' exit if argument not in range
  If ToIndex < 0 Or ToIndex > ctrl.ListCount - 1 Then Exit Sub
  
  With ctrl
    ' save text and data of the current item
    sText = .List(FromIndex)
    lItemData = .ItemData(FromIndex)
    ' remove the item
    .RemoveItem FromIndex
    ' add the item
    .AddItem sText, ToIndex
    .ItemData(.NewIndex) = lItemData
    ' select the new item
    .ListIndex = ToIndex
  End With
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.