Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems adding change order buttons on list box

Status
Not open for further replies.

N2PCS

IS-IT--Management
Jul 14, 2003
32
0
0
US
I have a form that has two list boxes on it. The List boxes are being populated by reading a text file. List box 1 only displays the actual text while list box two is a replica of the the text file. (Used to write the data back to the text file)

I am trying to add change order buttons to list box 1 so that users can change the display order of the data.

I have run in to a brick wall trying to fiuge this one out.

Any one ever done this, willing to help?

Thanks!

Scott
 
Hey Scott what's the specific problem?


Casper

"I feel sorry for people who don't drink. When they wake up in the morning, that's as good as they're going to feel all day."
~Frank Sinatra
 
What happens on Form_Load I write the text file data to a list box(list1). The the formated data gets added to lstAccount list box, which is the one I am trying to add function to.

I have two text boxes, text1 and text2. On the move down event I write the current values for the indexes to these fields, remove the data and write it back to the new index order but I can not seem to get the data written back in the correct order.

Code for function:

Private Sub cmdMoveDown_Click()
On Error GoTo Errors

Dim strSelected As String
Dim strTotal As String
Dim srtStart As String
Dim strEnd As String

strTotal = lstAccounts.ListCount
strSelected = lstAccounts.ListIndex

If strSelected = -1 Then
MsgBox "You must first select an item", vbExclamation, App.ProductName
Else
If strSelected = strTotal - 1 Then
MsgBox "Selected item is already at the bottom of the list.", vbExclamation, App.ProductName
Else
strStart = strSelected
strEnd = strSelected + 1

Text1.Text = lstAccounts.Text

lstAccounts.ListIndex = lstAccounts.ListIndex + 1
Text2.Text = lstAccounts.Text

lstAccounts.ListIndex = lstAccounts.ListIndex - 1

lstAccounts.RemoveItem strStart
lstAccounts.RemoveItem strEnd

lstAccounts.AddItem Text2.Text, strStart
lstAccounts.AddItem Text1.Text, strEnd
lstAccounts.Refresh
list1.Refresh


End If
End If

Errors:
If Err <> 0 Then
ShowError
End If

Thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top