在vb.net中,一个程序怎样接受外部的命令行 参数
我用vb.net编了一个程序B,这个程序由另一个程序A调用,当A在程序内调用B程序时,向B程序传递一些参数,我想知道在vb.net程序中怎样实现,在启动时接受,命令行参数,谢谢了
问题点数:50、回复次数:4Top
1 楼yinweihong()回复于 2006-05-04 09:21:07 得分 0
Command 函数
返回用于启动 Visual Basic 或使用 Visual Basic 开发的可执行程序的命令行的参数部分。
My 功能可以提供比 Command 函数更高的效率和更好的性能。有关更多信息,请参见 My.Application.CommandLineArgs 属性。
Public Function Command() As String
备注
参数返回后,您可以搜索常用分隔符(如空格、反斜杠、正斜杠、连字符或引号)断开或搜索单个参数的字符串。
对于用 Visual Basic 开发的且编译为 .exe 文件的应用程序,Command 函数返回在命令行中出现于应用程序名称后的任何参数,其格式为:MyApp(cmdlineargs)。
自己找MSDNTop
2 楼lyj670(空中一只鸟)回复于 2006-05-04 10:21:20 得分 0
My.Application.CommandLineArgs 这个属性没查到,
Public Function Command() As String
这个要怎么用?就是我在程序A中该程序用?Top
3 楼3tzjq(永不言弃)回复于 2006-05-04 11:51:13 得分 0
App A:
public shared sub main(arg as string)
application.run(new frmOpenFile(arg))'假设frmOpenFile是个打开文件的窗体
end sub
public class frmOpenFile
public sub new(file as string)
'....窗体初始化
if(file = "") then return
messagebox.show(file)'测试传入的参数
end sub
end class
App B:
打开程序A:process.start("..\AppA.exe","c:\Demo.txt")Top
4 楼Brunhild()回复于 2006-05-05 16:31:40 得分 0
System.Environment.GetCommandLineArgs()
也可以Top




