命令行参数允许用户或其他程序向程序传送启动信息。例如:程序名为test.exe,可以运行以下命令:
test.exe/help
在VB6中,可以使用Command属性读取它。在Vb.NET中,它已替换为System.Environment.GetCommandLineArgs函数,该函数返回一组传送的启动参数。
代码如下:
|
Dim myArg() As String, iCount As Integer
myArg = System.Environment.GetCommandLineArgs
For iCount = 0 To UBound(myArg)
TextBox1.Text = TextBox1.Text & "|" & myArg(iCount).ToString
Next
|
本文介绍了如何在VB.NET中使用System.Environment.GetCommandLineArgs函数来读取和解析命令行参数。通过示例代码展示了如何将这些参数显示在一个文本框中。
1832

被折叠的 条评论
为什么被折叠?



