Solved

exit sub ... end sub ..??!?

Posted on 1999-01-25
4
430 Views
Last Modified: 2010-05-03
what's the different between exit sub and end sub ?

will exit sub make a form stay active (hide but not shown) even when you terminate the application ?

thanks
0
Comment
Question by:tsung
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
CraigLazar earned 50 total points
Comment Utility
Hi
Exit sub - means thath if say you have a procedure or a value thath is reached and you want the execution of your sub routine to stop and not carry on . form still stays open

end sub - means thath the code in a sub routine has all been executed and that object is now finnished

Example - Exit sub
say u put in a validatioon on a field like this
Private sub Field1_lostfocus()
   the value in field1 is either null or a value u are not happy with
i use exit sub like this
if field1 = "" then
   field1.setfocus
   exit sub
end if

or in an error handler you will use exit sub often cause say the user has not filled in correct info so you do not want your app to bom so place an exit sub to prevent it and force the user back to were he should go or give them an message box or something

hope it helps

Craig
0
 
LVL 7

Expert Comment

by:Inteqam
Comment Utility
what is the sub you are using those two on?

0
 

Author Comment

by:tsung
Comment Utility
like you said Craig, if i use exit sub, this mean the form will not get closed ? then will it be danger if i replace the exit sub with "unload me" ? coz i just have an exprience yesterday that the program didn't get terminate althought the last form got unloaded. and that was happended during the development.
0
 
LVL 4

Expert Comment

by:CraigLazar
Comment Utility
Well friend u can try that, so so u want to close that form automatically ?
if so i would make a safer rout in thath not firectly replace exit sub with unload me . What i would do is create an small sub routine say called exitform. I would replace your exit sub with
call exitform
in exit form i would then call unload me

try that
ps.if u still have problems or unsure mail me the piece of code and i will look at it for you clazar@softnet.co.za
good luck
Craig

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 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

9 Experts available now in Live!

Get 1:1 Help Now