Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Control Matrix

Status
Not open for further replies.

carlosweiss

Programmer
Sep 15, 2005
15
0
0
AR
Hi,

I want to add a matrix of controls at runtime. If I write:

Set ctrls(i) = Me.Controls.Add("VB.Label", myCtrl(i))

I get an error. Any ideas on this? should I declare it first? how?

Thanks,

Carlos
 
Easy way is to put one label on the form at design time and set its Index property to 0. Then use the Load statement for the subsequent labels in the matrix, calculating their positions from the Index value:
Code:
For e = 1 To n - 1
  Load Label1(e)
   With Me.Label1(e)
   .Visible = True
   .Top = 300 + 400 * e
  End With
Next e

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top