Results 1 to 12 of 12

Thread: [RESOLVED] using the underscore

  1. #1

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Resolved [RESOLVED] using the underscore

    hi all i was aware that you can use a underscore to continue routines onto another line does this work for if statments also? because i keep getting error a syntax when i try it
    Last edited by Hack; Jun 8th, 2006 at 12:51 PM. Reason: Added [RESOLVED] to thread title and green "resolved" checkmark

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: using the underscore

    It should be fine for any line of code, as long as you do it properly.

    Show us what you have, and we'll fix it for you.

  3. #3
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: using the underscore

    If you find any issues to break and continue lines why don't you use the tools that will break lines and continue lines like MZ tools which is a free addin.

    show us the example where you get errors?
    CS

  4. #4

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: using the underscore

    alright i've got labels in a control array that i'm checking to see if they are not enabled ( now if there is an easier way than a if statment feel free to tell me the easier way as i'm just throwing this together quite quick and the coding may be a bit sloppy)

    VB Code:
    1. If Me.lblScore(1).Enabled = False and  Me.lblScore(2).Enabled = False and Me.lblScore(3).Enabled = False and Me.lblScore(4).Enabled=False [COLOR=Red]_[/COLOR]
    2. and me.lblscore(5).enabled =false

  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: using the underscore

    that will work if you have 'Then' on the end

    you could use a loop:
    VB Code:
    1. Dim bAnyEnabled As Boolean
    2. For N = lblScore.LBound To lblScore.UBound
    3.     If lblScore(N).Enabled Then bAnyEnabled = True: Exit For
    4. Next N
    5. If Not bAnyEnabled Then
    6.     '
    7.     '
    8.     '

  6. #6

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: using the underscore

    ah ok what i was trying to avoid was to have such a large if statment ( as there is 13 lables) the loop also was an idea i didnt think of bust silly me i explained it wrong i was actually trying to check if ALL the controls are disabled
    not just one at a time

  7. #7
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: using the underscore

    the code i posted will check if any of the labels are enabled - which is the same thing as checking that they are all disabled.

  8. #8

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: using the underscore

    lol good point i modified it before realizing that i dont know where my logic is at 2 day

  9. #9

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: using the underscore

    alright i dont know if i should post this in another thread or not if so just say the word and i will. in the program when the mouse moves over the lablels (lblscore)
    it displays the score and when you click on it it disables the label. how can i have it so i cant click on more than one label in the array once i already clicked a label ?

  10. #10
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: using the underscore

    either set a form-level flag variable:
    VB Code:
    1. Private bNoClick As Boolean
    2.  
    3. Private Sub lblScore_Click(Index As Integer)
    4.     If bNoClick Then Exit Sub Else bNoClick = True
    5.     ' Click Code
    6. End Sub
    or a static local variable:
    VB Code:
    1. Private Sub lblScore_Click(Index As Integer)
    2.     Static bNoClick As Boolean
    3.     If bNoClick Then Exit Sub Else bNoClick = True
    4.     ' Click Code
    5. End Sub
    or do a check everytime:
    VB Code:
    1. Private Sub lblScore_Click(Index As Integer)
    2.     Dim N As Long
    3.     For N = lblScore.LBound To lblScore.UBound
    4.         If Not lblScore(N).Enabled Then Exit Sub
    5.     Next N
    6.     ' Click Code
    7. End Sub
    there may be other ways too...

  11. #11

    Thread Starter
    Fanatic Member dark_shadow's Avatar
    Join Date
    Feb 2005
    Location
    Igloo
    Posts
    900

    Re: using the underscore

    alright thanks sorry for the stupid questions i know there simple i just cant seem to think today one of those days...

  12. #12
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: using the underscore

    When you have received an answer to your question, please mark it as Resolved using the Thread Tools menu.
    CS

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