• Return codes (VB 6)

    Author
    Topic
    #375534

    I would like to create a simple program, with no windows using VB. I would like to return a code to the calling process. The calling process will be a batch file. I want to check for ERRORLEVEL.

    How do I pass this return value back to the cmd shell? Or can’t I?

    Thanks

    Viewing 0 reply threads
    Author
    Replies
    • #611499

      You can use the ExitProcess API function, but you might want to consider alternative approaches.

      But first (so that our advice can be more useful) , can you tell us what you are trying to accomplish?

      • #611671

        What I am trying to accomplish is a workarround. We have an Oracle process which will launch an NT process, which will update PLCs on the shop floor. I need to return success or failure.

        • #611814

          Alternative 1:
          In your VB app, write out a dummy file if the process succeeds. Let’s say, C:PLCUPD.TXT.
          Then, your batch file tests for the presence of this file with

          If Exist c:plcupd.txt goto Success
          .
          .
          goto end
          :Success
          del c:plcupd.txt
          rem And your other code here…

          • #611834

            Actually I like the ExitProcess better. As long as I make sure everything is cleaned up, i.e. references to objects set to nothing, it appears to be OK. I watched the performance monitor and did not see any increasing thread counts, memory usage, etc. Using the ExitProcess API Function, the return code is returned to the calling environment. Though it is not likely, it is possible for two operators to call this process at once.

            I did notice that Daniel Appleman recommends against using ExitProcess.

            • #611846

              >>I did notice that Daniel Appleman recommends against using ExitProcess.
              Yes, and do you know why?

            • #612078

              I do not know why. I assume it because it brings the process to a dead halt, unlike posting a WM_CLOSE message to a window.

              Elightenment will be appreciated.

            • #612159

              Instantiated objects are left in memory. Files opened are left open. I think it’s like using End in VB

              Actually, WM_CLOSE with SendMessage is a better way, according to Mr. Appleman.

              If you have taken care of closing files, etc., ExitProcess should work fine.

    Viewing 0 reply threads
    Reply To: Return codes (VB 6)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: