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:
  1. For l = 0 To m_CurrScore.lSize
  2.     If l > cmdBlock.UBound Then Call Load(cmdBlock(l))
  3.  
  4.     cmdBlock(l).Caption = m_sChrs(l)
  5.     cmdBlock(l).Visible = True
  6.  
  7.     cmdBlock(l).Top = (((cmdBlock(l).Height + 10) * Int(l Mod 4)) + 8)
  8.     cmdBlock(l).Left = (((cmdBlock(l).Width + 10) * Int(l / 4)) + 8)
  9.   Next l