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
Printable View
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
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.
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?
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:
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] and me.lblscore(5).enabled =false
that will work if you have 'Then' on the end ;)
you could use a loop:VB Code:
Dim bAnyEnabled As Boolean For N = lblScore.LBound To lblScore.UBound If lblScore(N).Enabled Then bAnyEnabled = True: Exit For Next N If Not bAnyEnabled Then ' ' '
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
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.
lol good point i modified it before realizing that :( i dont know where my logic is at 2 day :(
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 ?
either set a form-level flag variable:or a static local variable:VB Code:
Private bNoClick As Boolean Private Sub lblScore_Click(Index As Integer) If bNoClick Then Exit Sub Else bNoClick = True ' Click Code End Subor do a check everytime:VB Code:
Private Sub lblScore_Click(Index As Integer) Static bNoClick As Boolean If bNoClick Then Exit Sub Else bNoClick = True ' Click Code End Subthere may be other ways too...VB Code:
Private Sub lblScore_Click(Index As Integer) Dim N As Long For N = lblScore.LBound To lblScore.UBound If Not lblScore(N).Enabled Then Exit Sub Next N ' Click Code End Sub
alright thanks sorry for the stupid questions i know there simple i just cant seem to think today :( one of those days...
When you have received an answer to your question, please mark it as Resolved using the Thread Tools menu.http://www.vbforums.com/images/ieimages/2004/12/1.gif