HOWTO:在Dos下用批处理文件执行编译后得到的Exe文件,并得到它的返回值?

1.生成一个Visual Basic Console Application,如何使其能够返回值?(Sub Main函数似乎不能改写成Function)

2.在Dos下用批处理文件执行编译后得到的Exe文件,如何得到它的返回值?

如上

---------------------------------------------------------------

1. sub Main可以改为function Main as integer
2. 可以用errorlevel判断

Module Module1

Function Main() As Integer
Dim s As String = Console.ReadLine
Return Integer.Parse(s)
End Function

End Module

run.bat
@echo off
"C:\Documents and Settings\cao.CTL\My Documents\Visual Studio Projects\ConsoleApplication1\ConsoleApplication1\bin\ConsoleApplication1.exe"

if %errorlevel%==0 goto OK
if %errorlevel%==1 goto Error
goto end

:OK
echo return ok
goto end

:Error
echo return error

:End
pause

Published At
Categories with Web编程
Tagged with
comments powered by Disqus