|
Prev: Autoredraw
Next: 2 Questions on ActiveX Controls
From: Peter on 16 Jul 2008 08:03 Dear all Is there a way to generate a return code that my VB6 app can pass to the OS. I like to call my VBapp from a DOS-Batch file(.bat) and when my VBapp ends I like to pass a return code so that the following IF ERRORLEVEL statement in the batchfile can branch in case a problem arised. Regards Peter
From: Jeff Johnson on 16 Jul 2008 09:12 "Peter" <peter_l(a)myrealbox.com> wrote in message news:g5ko1p$fu6$1(a)mail1.sbs.de... > Is there a way to generate a return code that my VB6 app can pass to the > OS. > I like to call my VBapp from a DOS-Batch file(.bat) and when my VBapp ends > I like to pass a return code so that the following IF ERRORLEVEL statement > in the batchfile can branch in case a problem arised. http://groups.google.com/advanced_search "return code vb"
From: Peter on 16 Jul 2008 09:36 Thanks, found the following when using your search link. Is this the recommended way? ------------------------------------------------------------------------- Yes, by using the ExitProcess Api function. Note however there are some precautions you must take to use it safely. ExitProcess does not allow VB to do it's normal cleanup, so you need to make sure that all forms are unloaded and all obj refs have been set =Nothing before using it. Attempting to use it when the app is running in the IDE will crash VB. I'd also suggest only using it in a native-code exe. In a p-code exe it will occassionally throw a system error. Probably harmless at that stage, but the error msgbox is annoying and not what you want your users to see. I'd suggest using it with conditional so as not to run it in IDE mode. Ex: 'declaration... Public Declare Sub ExitProcess Lib "kernel32" _ (ByVal uExitCode As Long) 'generic IDE mode detection... Public Function IsIDE() As Boolean Debug.Assert Not TestIDE(IsIDE) End Function Private Function TestIDE(Test As Boolean) As Boolean Test = True End Function 'usage... '...cleanup here... If Not IsIDE() Then ExitProcess 1 End If Regards Peter "Jeff Johnson" <i.get(a)enough.spam> schrieb im Newsbeitrag news:ebwKJW05IHA.1592(a)TK2MSFTNGP04.phx.gbl... > "Peter" <peter_l(a)myrealbox.com> wrote in message > news:g5ko1p$fu6$1(a)mail1.sbs.de... > >> Is there a way to generate a return code that my VB6 app can pass to the >> OS. >> I like to call my VBapp from a DOS-Batch file(.bat) and when my VBapp >> ends I like to pass a return code so that the following IF ERRORLEVEL >> statement in the batchfile can branch in case a problem arised. > > http://groups.google.com/advanced_search > > "return code vb" >
From: Jeff Johnson on 16 Jul 2008 10:59 "Peter" <peter_l(a)myrealbox.com> wrote in message news:g5ktgi$8r3$1(a)mail1.sbs.de... > Thanks, found the following when using your search link. > Is this the recommended way? Not so much "recommended" as "only"....
From: christery on 16 Jul 2008 13:35
On 16 Juli, 16:59, "Jeff Johnson" <i....(a)enough.spam> wrote: > "Peter" <pete...(a)myrealbox.com> wrote in message > > news:g5ktgi$8r3$1(a)mail1.sbs.de... > > > Thanks, found the following when using your search link. > > Is this the recommended way? > > Not so much "recommended" as "only".... Ehh, might write it to a text file just to oppose to the "only way"... its not the way I would go, but... gone there sometime when it just dies... //CY |