如何将值从vb.net返回到批处理文件并在批处理文件中打印? [英] How to return value from vb.net to batch file and Print It in batch file?

查看:111
本文介绍了如何将值从vb.net返回到批处理文件并在批处理文件中打印?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Team,



Hi Team,

Batch File:
@echo off
cls
TestApplication.exe

Print value: 
0,1,2,3,....,10.

Pause

VB.Net Application:
Project Name: TestApplication
Module Module1
    Sub Main()
        For index = 0 To 10
            //send index value to batch file
            //How to do that...
        Next
    End Sub
End Module





给出解决方案,

如何将值返回到批处理文件并在提示中自行打印。



先谢谢。



Give the solution,
How to return values to the batch file and print it in prompt itself.

Thanks in Advance.

推荐答案

你不能:你只能从你的应用程序返回一个整数值到调用环境。



如果你想返回更复杂的东西,然后我建议您通过命令行将文件名和路径传递给您的应用程序,使用您的应用程序写入文件,然后从批处理文件中的文件中打印结果。
You can't: you can only return a single integer value from your application to the calling environment.

If you want to return anything more complex, then I would suggest you pass a file name and path into you application via the command line, write the file with your app, and then print the result from the file in your batch file.


从应用程序循环返回值没有直接的方法如果这是你想要做的。您可以做的是您可以将一个值返回到批处理文件,如下例所示,并在批处理文件中的%ERRORLEVEL%变量中接收它。希望这会有所帮助。



公共函数Main(ByVal Args()As String)As Integer

索引= 1到10

//做点什么

下一页

返回1

结束功能





批处理文件

TestApplication.exe

echo%ERRORLEVEL%
There is no straight forward way to return value in loop from an application If this is what you are trying to do. What you can do is you can return one value to batch file like given in the below example and receive it in %ERRORLEVEL% variable in the batch file. Hoping this would help.

Public Function Main(ByVal Args() As String) As Integer
For index = 1 To 10
//Do something
Next
Return 1
End Function


Batch file
TestApplication.exe
echo %ERRORLEVEL%


这篇关于如何将值从vb.net返回到批处理文件并在批处理文件中打印?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆