Results 1 to 6 of 6

Thread: Sorting controls

  1. #1

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303

    Question

    Is there a simple way of sorting out command buttons for example in order from top to bottom of the screen, in order of their index number or even caption.

    If so how?
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    What exactly do you mean by 'Sorting Out' the command buttons?




    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  3. #3

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303
    Display them in a certain order Index 0-5 for example from the top to bottom of the screen.
    Command 1 index 0
    Command 2 index 1
    Command 3 index 2
    etc

    Hope this makes a little more sense
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Code:
    private sub form1_load()
       Dim i as integer, i2 as integer
       i = 400
       
       for i2 = 0 to 5
           cmd(i2).top = i
           i = i + 400
       next i   
    end sub
    Type of thing? if you set all the names of the command buttons to cmd (and have 6 of them), choosing yes to create a control array, this should work.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810
    Same thing but copes with random height buttons:
    Code:
    Private Sub Form_Load()
    
        Dim lngTop      As Long
        Dim lngLeft     As Long
        Dim lngSpace    As Long
        Dim intLoop     As Integer
        
        lngTop = 100    'Top of first button
        lngLeft = 100   'Left alignment (all buttons)
        lngSpace = 100  'Button spacing
        
        For intLoop = 0 To 5
            With Command1(intLoop)
                .Caption = "Button " & intLoop
                .Move 100, lngTop
                lngTop = .Top + .Height + lngSpace
            End With
        Next intLoop
        
    End Sub
    Change the lngTop, lngLeft & lngSpace to suit
    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  6. #6

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303
    Thanks everyone that sorted, really simple to, I don't know how I missed that one, must be looking to hard
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

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