Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Western NY, USA
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Return codes (VB 6)

    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

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Return codes (VB 6)

    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?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Western NY, USA
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Return codes (VB 6)

    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.

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Return codes (VB 6)

    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 clcupd.txt goto Success
    .
    .
    goto end
    :Success
    del clcupd.txt
    rem And your other code here...
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Western NY, USA
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Return codes (VB 6)

    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.

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Return codes (VB 6)

    >>I did notice that Daniel Appleman recommends against using ExitProcess.
    Yes, and do you know why?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  7. #7
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Western NY, USA
    Posts
    157
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Return codes (VB 6)

    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.

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Return codes (VB 6)

    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.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •