Solved

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

Posted on 1999-01-25
4
450 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to create a duplicate finder Application 9 121
bit defender blocks good applications 2 94
Copy a row 12 62
vb6 - Transfer from MSHFlexgrid1 to xls issue 8 52
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

810 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