Solved

Setting the DOS errorlevel in VB5.0

Posted on 1997-07-29
2
379 Views
Last Modified: 2008-03-17
How can I set the good old DOS errorlevel in Visual
Basic 5.0 when the program exists? I have an existing
application (that I can't change) but can call a VB program, and uses the errorlevel for testing.
0
Comment
Question by:arrow
2 Comments
 
LVL 9

Accepted Solution

by:
cymbolic earned 50 total points
ID: 1429001
You know, you're really in trouble on this one, because you have to communicate between two separate processes and two separate address spaces - you're not in Kansas anymore, Toto!

Here's what I'd do: Modify your VB app to write an error level in a file.  Write another DOS App that shells your VB app, keeps checking for the file, reads the file, and returns a DOS errorlevel to your old DOS app.  Since you run both the old DOS app and the new sheller/errorlevel returner in the same DOS box, they can pass errorlevels between them.  Hey, you can even use a DOS batch process in your DOS box!

If you need any help with this, I have already coded the same thing, once I realized I wasn't in Kansas anymore!
0
 

Expert Comment

by:sbugachevsky
ID: 1429002
You don't have to bother with any flag files.  Here's how you set the errorlevel from a VB program.

Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)

public sub main()
    call ExitProcess(_put_your_error_code_here)
end sub


0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

708 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