Solved

terminate executing code

Posted on 1998-05-27
5
161 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

624 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