|
-
Mar 9th, 2004, 02:18 PM
#1
Thread Starter
Hyperactive Member
CommandButton Array
I create a command button array using the following code, but currently the code is preset to 24 buttons. I'm trying to expand the code so that I can create a grid with x amount of buttons, specified by the user in the format 5x2, 4x6 etc.
Yet for the life of me I can't figure out how to do it, could someone please have a look at the code and advise - cheers!
-adehh
m_CurrScore.lSize = 23
VB Code:
For l = 0 To m_CurrScore.lSize
If l > cmdBlock.UBound Then Call Load(cmdBlock(l))
cmdBlock(l).Caption = m_sChrs(l)
cmdBlock(l).Visible = True
cmdBlock(l).Top = (((cmdBlock(l).Height + 10) * Int(l Mod 4)) + 8)
cmdBlock(l).Left = (((cmdBlock(l).Width + 10) * Int(l / 4)) + 8)
Next l
-
Mar 9th, 2004, 02:26 PM
#2
Banned
This is a function I wrote some time ago.
You'll have to adjust it a bit, perhaps..
VB Code:
Public Sub CreateArray(totalcount As Integer, rowmax As Integer)
Dim cmdBtn As Control
Dim ctrRow As Long
Dim ctrCol As Long
Dim InitialLeft As Long
Dim InitialTop As Long
Dim OffsetV As Long
Dim OffsetH As Long
ctrRow = 0
ctrCol = 0
InitialLeft = 1920
InitialTop = 3000
OffsetV = 695
OffsetH = 2475
For i = 1 To totalcount
Load cmdDesktop(i)
cmdDesktop(i).Height = 450
cmdDesktop(i).Width = 2175
cmdDesktop(i).Visible = True
cmdDesktop(i).Top = InitialTop + (OffsetV * ctrRow)
cmdDesktop(it).Left = InitialLeft + (OffsetH * ctrCol)
If ctrRow < rowmax Then
ctrRow = ctrRow + 1
Else
ctrRow = 0
ctrCol = ctrCol + 1
End If
Next
End Sub
-
Mar 9th, 2004, 02:31 PM
#3
Thread Starter
Hyperactive Member
Ahh, I grew attached to my mod\divide method, looks like I'm gonna have to drop it.
Cheers all the same.
-adehh
-
Mar 9th, 2004, 05:36 PM
#4
Thread Starter
Hyperactive Member
I'm getting closer and closer to solving this. Modified my code as below and half of the grid is displayed correctly, but it just places the second half of the grid in the same place as the first half. I kind of understand why it does this but can't think of a workaround.
Anyone?
VB Code:
cmdBlock(l).Top = (((cmdBlock(l).Height + 10) * Int(l Mod 4)) + 8)
cmdBlock(l).Left = (((cmdBlock(l).Width + 10) * Int(l Mod 6)) + 8)
-adehh
-
Mar 9th, 2004, 08:10 PM
#5
Lively Member
Could you please post all of the code, or put it up as a zip file? It's hard to determine what the problem is when you only give that.
-
Mar 10th, 2004, 01:07 AM
#6
Conquistador
VB Code:
Dim DefaultTop As Integer
Dim Rows As Integer, Cols As Integer
DefaultTop = cmdBlock(0).Top
Rows = 4
Cols = 5
For l = 1 To (Rows * Cols) - 1
If l > cmdBlock.UBound Then Call Load(cmdBlock(l))
cmdBlock(l).Caption = "Some Title " & l
cmdBlock(l).Visible = True
cmdBlock(l).Top = (cmdBlock(l - 1).Top + cmdBlock(l - 1).Height + 18)
cmdBlock(l).Left = cmdBlock(l - 1).Left
If (l Mod Rows) = 0 Then
cmdBlock(l).Top = DefaultTop
cmdBlock(l).Left = Int(l / 4) * (cmdBlock(l).Width + 10) + 8
End If
Next l
non ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|