Solved

terminate executing code

Posted on 1998-05-27
5
157 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

832 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