I need help how to put a label on all the frames in array ... one label visible on all the frames in array.
Printable View
I need help how to put a label on all the frames in array ... one label visible on all the frames in array.
Suggestions. For dynamically loading the labels in runtime
1. Place a label on the 1st frame in your array. Make its index = 0. I'll call it lblDefault
2. For each frame you want to add a label to
lblDefault(0) doesn't have to be in your first frame, it can be anywhere on the form, hidden or not.Code:Load lblDefault(lblDefault.UBound + 1)
With lblDefault(lblDefault.UBound)
Set .Container = FrameX(whateverIndex)
.Move newX, newY
.Visible = True
.Enabled = True
.Caption = newCaption ' only if needed else caption will be same as lblDefault(0)
' any additional properties you want set?
End With
my question is bit different i do not want to have any index=0 for label .. i have almost 100 frames in array and i want put a label on frame1(100) which is last frame index. if i call frame1(0) the label should remain there.
Using an array of labels should make coding easier. But you can add a label without an index also which requires you to create unique names for the labels...
To reference the label later in any code: Me.Controls("lblframe" & Index).ForeColor = vbBlueCode:' Index is the frame index, say 100 for this example
With Me.Controls.Add("VB.Label", "lblFrame" & Index, Frame1(Index))
.Caption = somecaption
.Move X, Y, Width, Height
. Enabled = True
. Visible = True
' other properties
End With
Edited: Maybe I am misunderstanding the question. Are you saying you want to move a single label around to multiple frames. In other words, 1 label shared by all your frames? If so, you will want to change containers for the label
Code:Set Label1.Container = Frame1(0)