I have a program that has names in ten text boxs. When I click on the two buttons that say ascending and descending the names are to be in ascending and descending order. Can someone give an example of how to do this.
Printable View
I have a program that has names in ten text boxs. When I click on the two buttons that say ascending and descending the names are to be in ascending and descending order. Can someone give an example of how to do this.
An easy solution would be to add an invisible listbox with the sort set to true.
When your program loads up, assign the names to the listbox. They will automatically sort in ascending order.
When someone clicks on the ascending sort button, use the following:
To do the decending, just do the reverse:Code:Private Sub Command1_Click()
'This is for a control array of text boxes.
For X = 0 To 9
Text1(X).Text = List1.List(X)
Next X
'This is for a set of textboxes named Text1 - Text10
Text1.Text = List1.List(0)
Text2.Text = List1.List(1)
Text3.Text = List1.List(2)
Text4.Text = List1.List(3)
Text5.Text = List1.List(4)
Text6.Text = List1.List(5)
Text7.Text = List1.List(6)
Text8.Text = List1.List(7)
Text9.Text = List1.List(8)
Text10.Text = List1.List(9)
End Sub
Hope this helps out.Code:'This is for a control array of text boxes.
For X = 9 To 0 Step - 1
Text1(X).Text = List1.List(X)
Next X
'This is for a set of textboxes named Text1-Text10
Text1.Text = List1.List(9)
Text2.Text = List1.List(8)
Text3.Text = List1.List(7)
Text4.Text = List1.List(6)
Text5.Text = List1.List(5)
Text6.Text = List1.List(4)
Text7.Text = List1.List(3)
Text8.Text = List1.List(2)
Text9.Text = List1.List(1)
Text10.Text = List1.List(0)