Results 1 to 13 of 13

Thread: Any Clue Will Help

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    19

    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

  2. #2
    Fanatic Member Bombdrop's Avatar
    Join Date
    Apr 2001
    Location
    St Helens, England, UK
    Posts
    667

    Re: Any Clue Will Help

    Try something like this.

    VB Code:
    1. Option Explicit
    2. Public x As Integer
    3.  
    4. Private Sub Command1_Click(Index As Integer)
    5.     Label1(x).Visible = True
    6.     x = x + 1
    7. End Sub

    Hope this helps!!

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Any Clue Will Help

    In the click event of the button array
    VB Code:
    1. CmdButton(Index).caption = mylabel(Index)

    or, if you want to display the label, use
    VB Code:
    1. mylabel(Index).visible = True

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Any Clue Will Help

    I'm not sure what your talking about. HTH:

    VB Code:
    1. ' Set all your labels .Visible=False first
    2. Private Sub cmdbtn_Click(Index As Integer)
    3. Static slngPrevIndex As Long
    4.     lbl(Index).Visible = True
    5.     lbl(slngPrevIndex).Visible = False
    6.     slngPrevIndex = Index
    7. End Sub

    that what you're after?

  5. #5
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Any Clue Will Help

    Quote 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:
    1. Option Explicit
    2. Dim nVis As Integer
    3.  
    4. Private Sub Form_Load()
    5.    nVis = -1
    6. End Sub
    7.  
    8. Private Sub Command1_Click(Index As Integer)
    9.    If nVis = 13 Then Exit Sub
    10.    nVis = nVis + 1
    11.    Label1(nVis).Visible = True
    12. 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)

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    19

    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

  7. #7
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    2048th post!

    In that case, krtxmrtz's code will work for you.

    Edit: BTW, to resolve your thread use the Thread Tools menu

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Any Clue Will Help

    Try this:
    VB Code:
    1. Dim ctrl As Control
    2.   For Each ctrl In Me.Controls
    3.       If TypeOf ctrl Is Label Then
    4.          If ctrl.Visible = False Then
    5.             ctrl.Visible = True
    6.             Exit For
    7.          End If
    8.       End If
    9.     Next
    Whatever label it hits first, that isn't currently visible, will become visible. It could be delightfully random.

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    19

    Re: Any Clue Will Help

    Quote 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:
    1. Option Explicit
    2. Dim nVis As Integer
    3.  
    4. Private Sub Form_Load()
    5.    nVis = -1
    6. End Sub
    7.  
    8. Private Sub Command1_Click(Index As Integer)
    9.    If nVis = 13 Then Exit Sub
    10.    nVis = nVis + 1
    11.    Label1(nVis).Visible = True
    12. End Sub
    how comes we don't use the end if

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    19

    Exclamation Re: Any Clue Will Help

    Quote 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:
    1. Option Explicit
    2. Dim nVis As Integer
    3.  
    4. Private Sub Form_Load()
    5.    nVis = -1
    6. End Sub
    7.  
    8. Private Sub Command1_Click(Index As Integer)
    9.    If nVis = 13 Then Exit Sub
    10.    nVis = nVis + 1
    11.    Label1(nVis).Visible = True
    12. 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

  11. #11
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Any Clue Will Help

    Quote 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)

  12. #12
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Any Clue Will Help

    Quote 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)

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Jul 2005
    Posts
    19

    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
  •  



Click Here to Expand Forum to Full Width