Results 1 to 9 of 9

Thread: showed form from executable file

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    showed form from executable file

    I have VB6 program and I have make it as executable *.exe files. How I can showed the VB6 form when I click the executable file?My path location of my vb6 is C:\Project\PF.exe. I know we can call the execuatable files using shell method, when I used it, it show my the form1 when I click the button because while make the executables files, I make form1 as start up. I trying to make a short cut by calling the form3

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

    Re: showed form from executable file

    Just add command line parameters to the program which specify the form to show. You can then use these parameters in a shortcut or via the Shell command.

    For information, see the article How can I use command line parameters in my program? from our Classic VB FAQs (in the FAQ forum, which is shown near the top of our home page)

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: showed form from executable file

    Not clearly understand bu I tryping to give a try.
    I have set up like this.. not sure if is correct.. I trying to open the form2 using command line..

    and in run command I typing like this C:\cuba\Project1.exe form2 .It show me the form1 because form1 is my start up.. Why it not show the form2?
    Attached Images Attached Images  

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: showed form from executable file

    That screen does not affect the program at all. It is just for testing inside VB itself - if you put form2 in there, it is the same as running C:\cuba\Project1.exe form2

    You need to add code to read the command line (Command), and perform whatever actions you want based on it - as shown in the article.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: showed form from executable file

    Ok.. I try to give a try with run command on my computer.. My start up object for executable files is "FORM1" . So I call it using run command like this

    C:\cuba\Project1.exe form2.. But not working.. It still show form1 form.. Why? Something wrong string I insert in the run command?
    Attached Images Attached Images  

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: showed form from executable file

    Please take the time to read what is posted:
    Quote Originally Posted by si_the_geek
    You need to add code to read the command line (Command), and perform whatever actions you want based on it - as shown in the article.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: showed form from executable file

    I put this code in form1 load and it show the form2 when I run using RUN command line

    Code:
    Private Sub Form_Load()
    Dim strCommandLine As String
    strCommandLine = Command
    Unload Me
    Form2.Show
    End Sub

    When I click the exe project.. It open the form2..Why? I have set up the form1 as start up..

  8. #8
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: showed form from executable file

    With the amount of experience you have, I am amazed that you can't work that one out.

    Putting a value to a variable does not do anything by itself - there is no magic involved in programming, you write the code to do things.

    You need to add some sort of control structure (like an If statement) to check what value it contains, and act on it as you want.


    As you have it, the code Form2.Show always runs, which means Form2 will always show.

  9. #9
    Hyperactive Member Teseng's Avatar
    Join Date
    Sep 2007
    Location
    Tupelo, MS
    Posts
    281

    Re: showed form from executable file

    Not sure if this is what you're after, but I'll give it a try.
    Code:
    Private Sub Form_Load()
    Select Case Command
    Case "Form1"    ' It was run like "C:/MyApp.exe Form1"
    Form1.Show
    Case "Form2"    ' It was run like "C:/MyApp.exe Form2"
    Form2.Show     
    Unload Me
    Case Else         'It was run with with something else in command line, so it shows Form1 and a popup
    MsgBox "Unknown Command!" 
    End Select
    End Sub
    Last edited by Teseng; Jun 12th, 2008 at 10:47 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
  •  



Click Here to Expand Forum to Full Width