Results 1 to 14 of 14

Thread: [RESOLVED] Moving items up and down in a listbox

Threaded View

  1. #11
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Moving items up and down in a listbox

    Another way of doing it...

    I don't have vb6 at the moment so I did it in Excel...

    Sure can work with slight amendments...

    Code:
    Dim i As Long, TouchMeNot As Boolean, pos As Long, strTmp As String
    
    Private Sub cmdUP_Click()
        pos = 0
        For i = 0 To ListBox1.ListCount - 1
            TouchMeNot = False
            If ListBox1.Selected(i) Then
                If i = pos Then TouchMeNot = True
                pos = pos + 1
                If TouchMeNot = False Then
                    strTmp = ListBox1.List(i - 1)
                    ListBox1.List(i - 1) = ListBox1.List(i)
                    ListBox1.List(i) = strTmp
                    ListBox1.ListIndex = i - 1
                    ListBox1.Selected(i) = False
                    ListBox1.Selected(i - 1) = True
                End If
            End If
        Next
    End Sub
    Private Sub cmdDN_Click()
        pos = ListBox1.ListCount - 1
        For i = ListBox1.ListCount - 1 To 0 Step -1
            TouchMeNot = False
            If ListBox1.Selected(i) Then
                If i = pos Then TouchMeNot = True
                pos = pos - 1
                If Not TouchMeNot Then
                    strTmp = ListBox1.List(i + 1)
                    ListBox1.List(i + 1) = ListBox1.List(i)
                    ListBox1.List(i) = strTmp
                    ListBox1.ListIndex = i + 1
                    ListBox1.Selected(i) = False
                    ListBox1.Selected(i + 1) = True
                End If
            End If
        Next
    End Sub
    Regarding the font the simplest way will be to use a picture like you suggested in post 1 or you could use Anibtn32.ocx to create animated button (I am not sure if vb6 supports it now. used to use it many years ago...)
    Last edited by Siddharth Rout; Jul 30th, 2009 at 03:18 PM. Reason: typo
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width