3 Replies - 72002 Views - Last Post: 03 January 2007 - 07:18 PM Rate Topic: -----

#1 demonzrulaz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 30-September 06

breaking out of a loop

Posted 03 January 2007 - 06:01 PM

Is there any way to break out of a loop in visual basic 6?
I know in java you can use the break statement to exit the loop but there is no break statement in vb.
Is This A Good Question/Topic? 0
  • +

#37 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: breaking out of a loop

Posted 03 January 2007 - 06:16 PM

Use the keyword Exit and the type of loop.
Example:
		Dim s As Integer
		s = 0
		Do Until s > 10

			If s >= 6 Then
				Exit Do  '   <----  This will cause loop to exit prematurely
			End If

			s += 1
		Loop


Was This Post Helpful? 1

#62 m2s87  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 390
  • Joined: 28-November 06

Re: breaking out of a loop

Posted 03 January 2007 - 06:20 PM

Or something like

for i=1 to 111
   if i>67 then exit for
next i


Hope it helps :D

This post has been edited by m2s87: 03 January 2007 - 06:21 PM

Was This Post Helpful? 1

#63 demonzrulaz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 30-September 06

Re: breaking out of a loop

Posted 03 January 2007 - 07:18 PM

thanks a lot guys
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1