ConsoleApplication return value different in Shell.ExitCode?

I have a ConsoleApplication which has a “Return 703” statement in its run event (this indicates a special “correct” answer).
The other application calls the ConsoleApplication using an asynchronous shell.

So, the console app (compiled) returns 703 (I’ve checked by issuing a “Print “I’m returning 703”” right before the return), but the calling shell’s ExitCode is 191…

Is that a boundary issue, like the shell using only a fixed integer’s length? Or some mapping is taking place? (then, how may I map 191 back to 703?).

I don’t think you can Return your own Exit Code because the Docs say “it returns a system-supplied exit code”.

You can only return a byte value (0-255), so only the last 8 bits of your value are showing up.


So a Return CType(703, UInt8) may work or does it mean only values up to 255 can be returned?

I don’t think there is a way to return a value less than zero or greater than 255.


I read this as “An exit code transmitted through the system"; I can be wrong, but I always assumed so.

This is a unexpected coincidence… I chose 703 randomly (already used 701 and 702, but not tried with them).
It turns out 703-(9th digit)=703-512=191, which happens to be a known number (192 being 64*3, often used). I was on the “192” track by mistake…

Ok, I’ll use numbers in the range 0-255.

Thank you!

Alternatively you can define a extended number value id, 254 or something… That then tells your application to read the longer number from x-bytes of the result message.

1 Like

Well, since I’m owning the console app, I’ve just defined codes inside the 0-255 range. Negative OS errors are rendered positive, out of bounds codes are moved to bounds and my 700-705 codes are now 70-75.