|
-
Aug 3rd, 2005, 10:45 AM
#1
Thread Starter
Junior Member
Any Clue Will Help
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
-
Aug 3rd, 2005, 10:59 AM
#2
Fanatic Member
Re: Any Clue Will Help
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!!
Useful Links
.Net
#Develop, GhostDoc, CodeKeep , be.PINVOKE, Good Code Snippet Site
Krypton Toolkit, XPCC / XP Common Controls, QSS Windows Forms Components
VB.COM
VB.Classic Help File, MB Controls, MZTools, ADO Stored Procedure Generator add-in,
-
Aug 3rd, 2005, 10:59 AM
#3
Re: Any Clue Will Help
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
-
Aug 3rd, 2005, 11:02 AM
#4
Re: Any Clue Will Help
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?
-
Aug 3rd, 2005, 11:06 AM
#5
Re: Any Clue Will Help
 Originally Posted by andytodd
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 
Offhand I think this should work (I have assumed the arrays' lower and upper bounds are 0 and 13)
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
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Aug 3rd, 2005, 11:21 AM
#6
Thread Starter
Junior Member
Re: Any Clue Will Help
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.
Last edited by andytodd; Aug 3rd, 2005 at 11:27 AM.
Reason: resolved
-
Aug 3rd, 2005, 11:28 AM
#7
2048th post!
In that case, krtxmrtz's code will work for you.
Edit: BTW, to resolve your thread use the Thread Tools menu
-
Aug 3rd, 2005, 11:32 AM
#8
Re: Any Clue Will Help
Try this:
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
Whatever label it hits first, that isn't currently visible, will become visible. It could be delightfully random.
-
Aug 3rd, 2005, 01:54 PM
#9
Thread Starter
Junior Member
Re: Any Clue Will Help
 Originally Posted by krtxmrtz
Offhand I think this should work (I have assumed the arrays' lower and upper bounds are 0 and 13)
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
how comes we don't use the end if
-
Aug 3rd, 2005, 02:07 PM
#10
Thread Starter
Junior Member
Re: Any Clue Will Help
 Originally Posted by krtxmrtz
Offhand I think this should work (I have assumed the arrays' lower and upper bounds are 0 and 13)
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
this works fine apart from it goes straight on to lbl(1) not lbl(0) even though its set in form_load as -1
-
Aug 3rd, 2005, 02:52 PM
#11
Re: Any Clue Will Help
 Originally Posted by andytodd
how comes we don't use the end if
Because Exit Sub is on the same line as If.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Aug 3rd, 2005, 02:53 PM
#12
Re: Any Clue Will Help
 Originally Posted by andytodd
this works fine apart from it goes straight on to lbl(1) not lbl(0) even though its set in form_load as -1
I've just tested it and lbl(0) is the first to become visible.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Aug 4th, 2005, 03:19 PM
#13
Thread Starter
Junior Member
Re: Any Clue Will Help
sorry it's just me i havent got a clue cheers for the hand out all the same
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
|