CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2013
    Posts
    1

    Passing parameters on launch

    Hi,

    I am writing a windows form application that will pass parameters on lauch. If the parameter length is <1 the program will run as default, otherwise if the length is greater I want to create a hardcoded variable to use globally. Can someone please let me understand how to do this?

    Here is what I would like to do, but is not working as expected:

    static void Main(string[] args)
    {
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);

    if (args.Length < 1)
    {

    Application.Run(new Form1());

    }
    else
    {
    Form1 frmForm1 = new Form1();
    MyVariable = "Test";
    }

    In this case, I would like to use "MyVariable" to help make decisions later in the application.

    Thank you in advance.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured