Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / December 2007



Tip: Looking for answers? Try searching our database.

Stopp a function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kashif Qureshi - 19 Dec 2007 23:26 GMT
Hi,

Is there anyway to stopp a function in before hand?

My problem is that I have a for-loop as shown below:

Private Function Count()

   For i = 30 To 0 Step -1
       code...
   Next

End Function

Lets say that I want to stopp the function or the for-loop before it has
reached 0, is there any way that I could do so?
I tryied by seeting i to 0, but it was not working.
Or even better, how do you stopp/kill a function you have started?

Please help.

thanx

//Kashif

*******
The brain is a wonderful organ; it starts working the moment you get up  in
the morning and does not stop until you get to the  office
*******
Jason Keats - 20 Dec 2007 00:23 GMT
| Hi,
|
[quoted text clipped - 20 lines]
|
| //Kashif

Private mbCancel As Boolean

Private Function Count()

   For i = 30 To 0 Step -1
       code...
       DoEvents
       If mbCancel Then Exit For
   Next i

End Function

Private Sub cmdCancel_Click()
   mbCancel = True
End Sub

In general, you should avoid using DoEvents. You must prevent other events
from being triggered while your loop is processing.

Also look at "Exit Do" for Do loops.

Hope this helps.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.