Solved

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

Posted on 1999-01-25
4
439 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
ID: 1470714
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
ID: 1470715
what is the sub you are using those two on?

0
 

Author Comment

by:tsung
ID: 1470716
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
ID: 1470717
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb.net 2008 2 56
Adding to a VBA? 6 62
Modifying Conditional Format from VBA code 3 49
Help with retrieving partial value from a column using VB.NET 4 44
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…
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…

895 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

13 Experts available now in Live!

Get 1:1 Help Now