Results 1 to 7 of 7

Thread: Couple of Qs

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Posts
    16

    Couple of Qs

    Using the shell() i call up mediaplayer and play a song given as the argument and use the notepad to read the song lyrics. But these application open up in minimized format instead of their normal/default mode

    My Q1 is : How do i open an executible file in the normal mode?


    I have total 3 forms and want to create a command button thru which i close all the forms and end the program. But i dont know how to do that (which command/function does that)

    My Q2: How do i close up all the open forms and terminate the app?

    Also could somebody tell me something about the Terminate and Unload functions.

    Any help is appreaciated

    PS: I'm a VB noob. Please bear with me if these are stupid and easy questions.

  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    The Shell command has a parameter to control what the shelled app window state is;

    Shell "notepad.exe",vbNormalFocus

    will make notepad appear in it's default position with focus.
    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  3. #3
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Q1
    VB Code:
    1. Shell "notepad.exe", vbnormalfocus

    Q2
    Your app, or the app you've just opened?

    Q3
    Unload?? as in Unload Form1
    Is so, that will close the form. You can use this in a loop to close all forms in your programs.
    Don't Rate my posts.

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Q1) The shell function supports 2 parameters (bit like when you call a program from dos, sometimes you can type extra arguments after it).

    VBMINIMIZEDFOCUS
    VBNORMALFOCUS
    VBMAXIMIZEDFOCUS

    Are 3 variables you can place at the end of the shell function (see above posts for sample code), which determine how the shelled application appears on the screen.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Q2)
    VB Code:
    1. Dim frm As Form
    2.  
    3. For Each frm In Forms
    4.     Unload frm
    5.     Set frm = Nothing
    6. Next frm

    When a form is loaded into the pc's memory (when the form_load event occurs before the form is shown to the user on the screen), the form object is added to a forms collection.

    In basic terms, think of a collection as a table - each cell contains a loaded form. What the above code does is to go through each cell in this table & kill the form. When the above loop finishes, the main form which was shown when you first started up or ran you application was unloaded and it's used reference it was taking up in the computers memory was wiped, so the whole program finishes excecution.

    Hope this makes sense!
    For more reading on this one, see the MSDN library for "Objects" and why you unload and set them to nothing to clear them.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  6. #6
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Q3) The terminate event fires when the object (form in this instance) has the space it was taking up in the pc's ram removed.

    The Unload event occurrs right before the form is removed from the screen so the user can no longer see it. This event occurrs before the above terminate event when you close a form!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Posts
    16
    Thanks everybody (esp. alex_read) just the kind of info i was looking for.

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