Solved

terminate executing code

Posted on 1998-05-27
5
155 Views
Last Modified: 2010-05-03
dear sir,

how to stop execute the executing code ?for example, consider the following code. if l ran this code, it would go to test function, now l would like to write a code in test function to stop executing. make sure it won't turn back to msgbox line.but not end the whole program, just to terminate executing the form1 only. how to do it ? if l write with unload function, it would be back to msgbox line.

private sub form_load()
test
msgbox "Test"
end sub

private sub test()
'some code here to stop executing
end sub
0
Comment
Question by:e_aks
  • 3
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
Anita030598 earned 30 total points
ID: 1461778
What's that you are trying to do? Somewhere it will come back.
However you can avoid executing the rest of the lines in Form_Load after test by setting a flag in test. Do it this way:

Dim bFlag As Boolean

private sub form_load()
test
if Not bFlag Then
   msgbox "Test"
end if
end sub

private sub test()
'some code here to stop executing
 bFlag = True
end sub
0
 
LVL 1

Expert Comment

by:Anita030598
ID: 1461779
you can add Unload Me after bFlag = True in test sub if you want the form to be not loaded as well.
0
 

Author Comment

by:e_aks
ID: 1461780
thanks, but is  this just only way to do it ?
0
 
LVL 1

Expert Comment

by:Anita030598
ID: 1461781
As far as I know this is one best and simple way to do.
0
 

Author Comment

by:e_aks
ID: 1461782
ok thanks.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now