|
-
Jun 24th, 2001, 05:32 AM
#1
Thread Starter
Hyperactive Member
How do i use the GOTO command?
i know its like really REALLY simple, but i dont know how to, and i cant find a tutorial, so if someone could plz gimme a crash course (very small, just so i can use it) because i kinda need it now, thanx
-
Jun 24th, 2001, 05:48 AM
#2
You only need to declare a label. do this by
Private Sub Command1_Click()
GoTo err
Exit Sub
err:
[labelname]:
[commands].....
End Sub
Its simple isn't it.
-
Jun 24th, 2001, 05:50 AM
#3
btw, i suggest you use this sparingly. I only user goto for
my error handlers. you may not want to have spaghetti codes.
just a thought.
-
Jun 24th, 2001, 05:51 AM
#4
Thread Starter
Hyperactive Member
what do you mean by a LABELNAME, why do i need a label, cant i just go
goto err:
end sub
err:
if blahdebvlahdeblah
-
Jun 24th, 2001, 05:58 AM
#5
Addicted Member
GoTo will jump to the specified lablel and continue from there.
GoSub will do the same, but it requires some kind of termination, such as Return or Exit Sub.
GoTo is useful if you want to skip a block of code based on some criteria.
GoSub is useful if you have a block of code that is repeated within a routine. You can move that code to a GoSub followed by Return and then just call it each time you would have re-executed the code.
GoTo statements really shouldn't be necessary, in most cases If..Thens and Error Handlers can replace them.
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
|