0

我需要能够将参数传递给我的 Windows 应用程序,以便我可以根据传递的参数运行代码:

下面是windows应用程序开始运行时调用的函数:我需要这个方法有参数。

Private Sub Start_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Try
        Dim Mgr As New StartMgr
        Mgr.Import()  // from here controls goes to a class library and it the whole //code, I need this function Import(arg) so that it can run partial code based on args

        Me.Visible = False
        Me.Close()
    Catch ex As Exception

    Finally
        Application.Exit()
    End Try

    End Sub
4

2 回答 2

2

如果你的意思是命令行参数,我认为除非你在你的类中添加一个属性,否则你无能为力。但是您始终可以通过此函数Environment.GetCommandLineArgs()访问参数。

于 2013-08-13T18:49:19.903 回答
2

您可以轻松地使用它:

Dim args As String() = Environment.GetCommandLineArgs()
TextBox1.Text = String.Join(".", args)
于 2017-06-14T18:27:37.047 回答