Okay, now I need some help.....I have been working on this for a full day...tried dozens of loops and ifs. Just CAN'T get the logic down.
What I want is rows of command buttons on a form....maybe 25 or so (for a game similar to Jeopardy).
I determine how many buttons go in a row by using form and button widths
I decide in advance how many buttons I want so determining number of rows is easy.
Now, what I can't seem to do is move down each set of buttons into rows.
Should look similar to this:
CMD1 CMD2 CMD3 CMD4 CMD5
CMD6 CMD7 CMD8 CMD9 CMD10
CMD11 CMD12 CMD13 CMD14 CMD15...well, you get the idea.
Here is my last/final failure----and I tried many...can anyone assist here?
What I want is rows of command buttons on a form....maybe 25 or so (for a game similar to Jeopardy).
I determine how many buttons go in a row by using form and button widths
I decide in advance how many buttons I want so determining number of rows is easy.
Now, what I can't seem to do is move down each set of buttons into rows.
Should look similar to this:
CMD1 CMD2 CMD3 CMD4 CMD5
CMD6 CMD7 CMD8 CMD9 CMD10
CMD11 CMD12 CMD13 CMD14 CMD15...well, you get the idea.
Here is my last/final failure----and I tried many...can anyone assist here?
Code:
Option Explicit
Private Sub Command2_Click()
Dim numCmdBtnsWanted As Integer
Dim numCmdBtnsAllowedInRow As Integer
Dim numRows As Integer
Dim z As Integer
numCmdBtnsAllowedInRow = Form1.Width / Command1(0).Width
numCmdBtnsWanted = 25
numRows = numCmdBtnsWanted / numCmdBtnsAllowedInRow
Dim x As Integer
Dim y As Integer
Dim wd As Integer
wd = Command1(0).Width
Dim ht As Integer
ht = Command1(0).Height
For x = 1 To numCmdBtnsWanted
Load Command1(x)
Command1(x).Caption = "CMD" & Str(x)
Command1(x).Visible = True
Next x
For x = 1 To numCmdBtnsAllowedInRow
Command1(x).Top = Command1(0).Top
Command1(x).Left = Command1(x - 1).Left + wd
Next x
End Sub