Results 1 to 4 of 4

Thread: C++-> VB6

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2005
    Posts
    230

    C++-> VB6

    In C++ there is a continue; instruction that we can use in a loop to return to the beginning of a loop. i just want to know if there's something similar in VB6.

    Thanks guy

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: C++-> VB6

    No. There isn't any. All you can use is a Label and GoTo.

    VB Code:
    1. Private Sub MySub()
    2.  
    3.     Do Until [Condition1] = False
    4.  
    5.         If [Condition2] = True Then
    6.             'Do some stuff
    7.             GoTo Continue
    8.         End If
    9.  
    10.         ' Do some other stuff
    11.  
    12.         If [Condition3] = False Then Exit Do
    13.         '
    14.         ' Rest of the code
    15.         '
    16. Continue:
    17.     Loop
    18.  
    19. End Sub
    Last edited by iPrank; Jan 20th, 2007 at 12:41 PM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: C++-> VB6

    Quote Originally Posted by iPrank
    No. There isn't any. All you can use is a Label and GoTo.

    VB Code:
    1. Private Sub MySub()
    2.  
    3.     Do Until [Condition] = True
    4.  
    5.         If [Condition2] = True Then
    6.             'Do some stuff
    7.             GoTo Continue
    8.         End If
    9.  
    10.         ' Do some other stuff
    11.  
    12.         If [Condition3] = False Then Exit Do
    13.         '
    14.         ' Rest of the code
    15.         '
    16. Continue:
    17.     Loop
    18.  
    19. End Sub
    I'm sorry but IMO using lables like that is a bad programming practice and if you ever think you need to use a label you should rethink the code. For example in your example wouldn't the loop end when you went back to the top because [Condition] is True? And if that's the case then Exit Do would be the thing to use rather than the Go To.

  4. #4
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: C++-> VB6

    Oh. Sorry. Edited the psudo code.
    And yes, you are right. Using Labels/GoTo not good a practice.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


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