I wanna make two programs in one.-VBForums
Results 1 to 8 of 8

Thread: I wanna make two programs in one.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    30

    I wanna make two programs in one.

    Hi guys
    I made to programs and I wanna put them into one program, something like I open a program and gives me two choices a.k.a buttons, If I choose button one, it opens program one, and If I choose button two, it opens program two.
    I don't wanna make connection like load file from C\: ..., I want to make it like database in the program.
    Hope you understood my ****** English!

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    39,516

    Re: I wanna make two programs in one.

    Do you actually want two programs?

    In most cases having two windows (aka Forms) is the way to go, and sometimes even merge them onto one window.

  3. #3
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,278

    Re: I wanna make two programs in one.

    Windows applications start up by showing a form.

    So you need to combine the code from both projects into one project, but make the startup form one with two buttons on it. Each button shows the right form for the selected program.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    30

    Re: I wanna make two programs in one.

    Quote Originally Posted by Sitten Spynne View Post
    Windows applications start up by showing a form.

    So you need to combine the code from both projects into one project, but make the startup form one with two buttons on it. Each button shows the right form for the selected program.
    Yeah

  5. #5
    Junior Member VBAppleCoder's Avatar
    Join Date
    Oct 2017
    Posts
    26

    Re: I wanna make two programs in one.

    Sounds like you should create three forms. The first form would have the two buttons and then the other forms would be what is displayed when you click either of the buttons. Is this what you are trying to accomplish?

    If this is the case, my example is I have a button "Go to Form 2". When clicked it will take you to that form. And lets say form 2's name property is form2. Then you would use this:

    form2.Show()

    This will show form 2 when you click that particular button.
    Last edited by VBAppleCoder; Dec 9th, 2017 at 08:44 PM.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    30

    Re: I wanna make two programs in one.

    Quote Originally Posted by VBAppleCoder View Post
    Sounds like you should create three forms. The first form would have the two buttons and then the other forms would be what is displayed when you click either of the buttons. Is this what you are trying to accomplish?

    If this is the case, my example is I have a button "Go to Form 2". When clicked it will take you to that form. And lets say form 2's name property is form2. Then you would use this:

    form2.Show()

    This will show form 2 when you click that particular button.
    If I export the project as exe, I am talking about the form that opens the two programs, does it require the other files to use them? for example I wanna copy them into CD, can I open both programs from the form without having them?

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    39,516

    Re: I wanna make two programs in one.

    If you create them as separate programs, you will need to distribute all of the programs in some way.

    If you add the code for them all to the same project (which is what all of us have described) then you will have just one exe file, which contains all the "programs".

    The example VBAppleCoder (and Sitten) described is that you have two separate projects at the moment, but merge them into one project (you can add existing forms to a project, or copy+paste, etc). Then create a new form which just has buttons to show the other forms, and is set as the start object for the project.

  8. #8
    Addicted Member Peter Porter's Avatar
    Join Date
    Jul 2013
    Posts
    161

    Re: I wanna make two programs in one.

    Quote Originally Posted by casper.mta View Post
    If I export the project as exe, I am talking about the form that opens the two programs, does it require the other files to use them? for example I wanna copy them into CD, can I open both programs from the form without having them?
    Casper, in your first post you asked for all your programs to be included into one. Everyone above informed you how to do this, but you either don't understand what they wrote, or you're not sure what you want.

    Within the project of the program that will launch the other two programs, click "Project" on top left, and within it's dropdown menu click "Add Windows Form". You will have to do this twice. After doing this you will have form2 & form3 where you would add the code for your other two programs.

    Make sure those forms (form2 & form3) are hidden.

    Also, in Form2_load and Form3_load add:
    Code:
    Me.ShowInTaskbar = False
    In Form1's buttons, from the same project you added your code, add for Button1_Click:
    Code:
    Form2.Show() 
    Form2.ShowInTaskbar = True
    for Button1_Click:
    Code:
    Form3.Show() 
    Form3.ShowInTaskbar = True
    This will launch and show the programs you combined with the project that starts them.

    In the end, all your programs have been placed into one, just what you wanted. There are no other programs to copy to the CD, because again, your programs have all been placed into one by extra forms.
    Last edited by Peter Porter; Dec 10th, 2017 at 09:08 AM.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.