I have two array's 14 cmdbtns and 14 lbls when a cmdbtn is clicked (any No) then lbl(0) will come visible when the second cmdbtn is clicked (any No) then lbl(1) will come visible and so on I know i need a loop any clues will help :D
Printable View
I have two array's 14 cmdbtns and 14 lbls when a cmdbtn is clicked (any No) then lbl(0) will come visible when the second cmdbtn is clicked (any No) then lbl(1) will come visible and so on I know i need a loop any clues will help :D
Try something like this.
VB Code:
Option Explicit Public x As Integer Private Sub Command1_Click(Index As Integer) Label1(x).Visible = True x = x + 1 End Sub
Hope this helps!!
:wave: :thumb: :wave:
In the click event of the button array
VB Code:
CmdButton(Index).caption = mylabel(Index)
or, if you want to display the label, use
VB Code:
mylabel(Index).visible = True
I'm not sure what your talking about. HTH:
VB Code:
' Set all your labels .Visible=False first Private Sub cmdbtn_Click(Index As Integer) Static slngPrevIndex As Long lbl(Index).Visible = True lbl(slngPrevIndex).Visible = False slngPrevIndex = Index End Sub
that what you're after?
Offhand I think this should work (I have assumed the arrays' lower and upper bounds are 0 and 13)Quote:
Originally Posted by andytodd
VB Code:
Option Explicit Dim nVis As Integer Private Sub Form_Load() nVis = -1 End Sub Private Sub Command1_Click(Index As Integer) If nVis = 13 Then Exit Sub nVis = nVis + 1 Label1(nVis).Visible = True End Sub
i dont want the same lbl(index) to become visible as to the same cmdbtn(index) that has been pressed.
I want to be able to click any cmdbtn(index) say for instance cmdbtn(5) and the next lbl(index) that is not visible to become visible.
In that case, krtxmrtz's code will work for you.
Edit: BTW, to resolve your thread use the Thread Tools menu ;)
Try this:Whatever label it hits first, that isn't currently visible, will become visible. It could be delightfully random.VB Code:
Dim ctrl As Control For Each ctrl In Me.Controls If TypeOf ctrl Is Label Then If ctrl.Visible = False Then ctrl.Visible = True Exit For End If End If Next
how comes we don't use the end ifQuote:
Originally Posted by krtxmrtz
this works fine apart from it goes straight on to lbl(1) not lbl(0) even though its set in form_load as -1Quote:
Originally Posted by krtxmrtz
Because Exit Sub is on the same line as If.Quote:
Originally Posted by andytodd
I've just tested it and lbl(0) is the first to become visible.Quote:
Originally Posted by andytodd
sorry it's just me i havent got a clue cheers for the hand out all the same