Results 1 to 4 of 4

Thread: Using the Exit statement, is this OK? (Resolved)

  1. #1

    Thread Starter
    PowerPoster SuperSparks's Avatar
    Join Date
    May 2003
    Location
    London, England
    Posts
    265

    Using the Exit statement, is this OK? (Resolved)

    I've had to put a For Next loop inside a Do While loop:

    VB Code:
    1. Do While i < 24
    2.             ' some code
    3.  
    4.             For j As Byte = 0 To 10
    5.  
    6.                 ' some more code
    7.                 If Rand(j) >= 33 AndAlso Rand(j) <= 126 Then
    8.                     If i = 24 Then Exit Do
    9.                   End If
    10.             Next
    11.  
    12.         Loop

    Is it OK to exit the Do While loop from within the For Next loop like that, or is it going to leave stuff on the stack? As usual MSDN Library is as clear as mud on the matter
    Last edited by SuperSparks; Jun 6th, 2004 at 12:49 PM.
    Nick.

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Never seen that. Don't know the correct answer, would seem it would be ok. Try it.
    Of course, you could exit the For loop first. Probably safer.

  3. #3
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    There is no problem with the stack here.

    It is perfectly acceptable to do that.

    Unless you are doing something like opening streams, and exiting the do loop before you've closed them, you wouldn't be able to predict in what order the objects are GC'd. But thats just a common-sense call.

    For general use its fine though.
    I don't live here any more.

  4. #4

    Thread Starter
    PowerPoster SuperSparks's Avatar
    Join Date
    May 2003
    Location
    London, England
    Posts
    265
    That's great. Thanks guys
    Nick.

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