Open or form1 or form2 at the start of the winform program

0

I have a program in vb6 and it has two buttons - One mara scanner and another one to consult scanned images. I created a program in C # winform in which the project has 2 forms - one form1 for the scanner and another form2 for the queries of the scanned images. The two on .Net works perfectly. I would like to know if there is a way to do this when running the .net program, using a parameter 1 or 2, to choose which of the forms will execute through VB6

In vb I intend depending on the button clicked, it will write to a table or 1 or 2. In the chosen button, you will call the application through the shell. Starting the application, I will consult the tabelacom the chosen parameter and open the requested form.

I just do not know how to do this in .Net C #. the start of Program.cs is like this in .NET

[STAThread]
static void Main()
{
    ConsultaImagens2 f2 = new ConsultaImagens2();
    Application.Run(f2);
    MainFrame f1 = new MainFrame();
    f1.Close();

    MainFrame mf = new MainFrame();
    ConsultaImagens mf = new ConsultaImagens();
    Application.Run(mf);
    MainFrame mf1 = new MainFrame();
    mf1.Close();
}
    
asked by anonymous 12.07.2016 / 23:28

1 answer

2

Yes, this is completely possible. For this you can use the parameters in the Main method. As you will call the executable at the prompt, just do

  

C: \ SomePackage > name Application.exe Appointments2

The code looks something like this:

Note: I did not understand why I instantiated that MainFrame so I removed it.

[STAThread]
static void Main(string[] args)
{
    Form formAbrir;

    if(args[1] == "ConsultaImagens2") //a posição 0 é sempre o caminho do arquivo
        formAbrir = new ConsultaImgens2();
    else
        formAbrir = new ConsultaImagens();

    Application.Run(formAbrir);
}
    
13.07.2016 / 04:12