Results 1 to 8 of 8

Thread: Open identical new form

  1. #1
    sorsater is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Feb 2012
    Posts
    3
    Reputation
    0

    Open identical new form

    Hi guys!

    I have a problem.
    I want to open a form that is identical to the previous one, like a new process but I have no clue on how i can do.

    Like if you doubleclicked the same icon to the program again but instead click a button in the program.
    I've tried to search on google and here but couldn't find anything.

    Hope you understand my question and my english.
    Thanks!

  2. #2
    JuggaloBrotha's Avatar
    JuggaloBrotha is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Jun 2004
    Location
    Lansing, MI; USA
    Posts
    4,334
    Reputation
    960
    What I would do is when you click the button in your program, write the needed info to get the next instance to show the same info that the current app has open then have it open a new instance of itself but pass it in a commandline arg so it knows to read that file. Then make your program check for the commandline arg and read the file, open the forms and all that.

    Though I'm curious to why you're looking to do such a thing in the first place.
    Currently using: VS 2010 Ultimate on Win7 Ultimate x64.


  3. #3
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,504
    Reputation
    1553
    Are you trying to actually transfer data entered by the user in the first instance to the second, or are you just saying that you want to run the same application a second time?

  4. #4
    sorsater is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Feb 2012
    Posts
    3
    Reputation
    0
    But I don't know which code I need to open a new instance.
    You don't need to write the whole code, just hint me in how I will do and then I think I will make it.

    Together with a friend I'm making a program for poker.
    You have a table where you fill in statistics from the game and we wan't to open a new table if you multitable.
    Like in File--> Add table

    Thanks!

  5. #5
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,504
    Reputation
    1553
    It would be nice if we really new what you wanted to do. You talk about starting a new process but it sounds like you just want to open a new form in the same process. I asked a question and you didn't answer it. Please provide a FULL and CLEAR explanation of the problem.

  6. #6
    sorsater is offline VB.NET Forum Newbie
    .NET Framework
    .NET 4.0
    Join Date
    Feb 2012
    Posts
    3
    Reputation
    0
    I want to run the same application again.
    An independent one.

  7. #7
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,504
    Reputation
    1553
    To start a new process in VB.NET you call Process.Start. To execute a file you pass the path of that file to Process.Start. The file path of the current executable can be found in a WinForms application using Application.ExecutablePath. So, you now know how to get the current EXE file path and you know how to execute a file by path. That's all you need.

  8. #8
    Gunzedreng is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Feb 2012
    Location
    Denmark
    Posts
    9
    Reputation
    0
    I would create a MainForm with a notifyIcon and a contextmenu attached to that so you could simply rightclick the icon in tray and add new Instance or something, where you in your code would add to Button_Click Event:

    Dim NewForm as New Form2
    NewForm.Show()

    where Form2 is the form you want a new instance of. in your case, your Poker table form.

    Gunze

Bookmarks

Posting Permissions

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