Results 1 to 2 of 2

Thread: ascending and descending arrays

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    Chicago
    Posts
    12

    Wink

    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.
    CorettaB

  2. #2
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    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:

    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
    To do the decending, just do the reverse:
    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)
    Hope this helps out.
    -Excalibur

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