how to write code using "goto"?
i get a compile error:expected:line number or label
Printable View
how to write code using "goto"?
i get a compile error:expected:line number or label
vb Code:
On Error GoTo ErrHandler 'your code here Exit Sub 'This keeps it from running the error handler every time ErrHandler: 'The name you gave it after the "GoTo" part msgbox Err.Number & vbcrlf & Err.Description
the answer is don't - unless you're using it for an error handler, in which case:Code:Private Sub Command1_Click()
On Error Goto ErrHandler
' Code
Exit Sub
ErrHandler:
MsgBox "Err!"
End Sub
Amen in spades.Quote:
Originally Posted by bushmobile
However, because you asked the question I'm assuming you have some code that isn't working and you feel that a GoTo could be a solution.
Show us what you have and what you want/need to do with it.