Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Return Codes from VB 1

Status
Not open for further replies.

msquaredmm

Programmer
Jul 26, 2002
2
0
0
US
I'm looking for a way to pass a return code from a VB EXE to the batch job that ran it. How can I pass a return value from VB to the job that executed it?

Thanks,
MM
 
If your using an ActiveX exe, you should be able to create an event that returns a variable. Then the form that calls the exe will need an event handler to be able to process the code.
 
You really, really don't want to know...

You might want to start looking at the ExitThread API, but if you're launching from a command line batch file you'll find this doesn't actually return an error code to the batch file. Why not? Well, that's where the problems start...

thread222-255803 - which is not a solution to your problem, does provide some discussion as to the issues of interaction between a VB program and a command line console.

There are ways to solve this, but they can be very ugly...
 
Try the following:

In your batch program, call the VB Exe like this:

start /w myProgram
if errorlevel 100 goto HereItIs

In the VB EXE use the following API:

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

And then, for instance, when clicking a command button:

Private Sub cmdButton1_Click()

ExitProcess 100&

End sub


 
Quite so. I was incorrectly thinking of something slightly different...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top