Results 1 to 5 of 5

Thread: How do i use the GOTO command?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312

    Talking 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

  2. #2
    Resty
    Guest
    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.

  3. #3
    Resty
    Guest
    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.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    what do you mean by a LABELNAME, why do i need a label, cant i just go

    goto err:
    end sub
    err:
    if blahdebvlahdeblah

  5. #5
    Addicted Member stevess's Avatar
    Join Date
    May 2001
    Posts
    251
    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
  •  



Click Here to Expand Forum to Full Width