|
-
May 13th, 2000, 12:56 AM
#1
Thread Starter
Fanatic Member
This is a bit foolish question bu I forgot how to do it.
I want to move items listed in the list box up or down. How do I do it?
Kinjal
-
May 13th, 2000, 01:35 AM
#2
transcendental analytic
Code:
Private Sub Form_Load()
For n = 0 To 10
List1.AddItem n
Next n
End Sub
Private Sub List1_Click()
List1.AddItem List1.List(List1.ListIndex), 1
List1.RemoveItem List1.List(List1.ListIndex + 1)
End Sub
Havent tested it yet but see if it works
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 13th, 2000, 01:43 AM
#3
Thread Starter
Fanatic Member
The items are already added to the list box and I wan to change their position i.e move the entries up or down using command buttons.
-
May 13th, 2000, 01:50 AM
#4
Thread Starter
Fanatic Member
No Kedaman it's not working. The program shows error whenever I click the list box.
-
May 13th, 2000, 02:02 AM
#5
transcendental analytic
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 13th, 2000, 08:30 AM
#6
Member
This seems to work. Create a new form with a listbox, and two command buttons. cmdUp and cmdDown. When the user highlights an item in the list, then clicks the up or down button, the highlighted item will move up or down...
Private Sub cmddown_Click()
Dim ts As String
Dim tindex As Integer
tindex = List1.ListIndex
If tindex < List1.ListCount - 1 Then
ts = List1.List(tindex + 1)
List1.List(tindex + 1) = List1.List(tindex)
List1.List(tindex) = ts
List1.ListIndex = tindex + 1
End If
End Sub
Private Sub cmdup_Click()
Dim ts As String
Dim tindex As Integer
tindex = List1.ListIndex
If tindex > 0 Then
ts = List1.List(tindex - 1)
List1.List(tindex - 1) = List1.List(tindex)
List1.List(tindex) = ts
List1.ListIndex = tindex - 1
End If
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 10
Me.List1.AddItem Str(i)
Next
End Sub
-
May 13th, 2000, 09:35 AM
#7
perfect.... thank you,
I needed this code too
-
May 13th, 2000, 02:03 PM
#8
Thread Starter
Fanatic Member
Thanks a lot jmatello. 
Kinjal
-
May 13th, 2000, 02:19 PM
#9
Conquistador
yeas, thank you, i was after this too
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|