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?
Printable View
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?
What exactly do you mean by 'Sorting Out' the command buttons?
.
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
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.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
Same thing but copes with random height buttons:
Change the lngTop, lngLeft & lngSpace to suitCode: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
:cool:
Thanks everyone that sorted, really simple to, I don't know how I missed that one, must be looking to hard :)