PBDR.COM

About   -   Contact   -   Purchase   -   Search   -   What's New

 
 
Shelling External Applications
The ability to call one VB app from another has several advantages. Most significantly this allows applications to be written as modular re-usable components and avoids large, overbearing executables from existing. In addition, information can be passed from one app to another for initialisation purposes. External apps, whether they be VB or not, are invoked using the Shell command as follows:
   Private Sub mnuLaunchApp()

      Dim lngVal as Long
      On Error Goto ErrorHandler
      lngVal = Shell(App.Path & "\myOtherApp.exe", 1)
      Exit Sub
   ErrorHandler:
      Msgbox "Problems encountered launching application", vbInformation

   Sub End

The App.Path signifies the same filepath as the one the current VB exe resides in, and the following argument determines the WindowsState of the invoke app, maximised, minimised, hidden etc.
Passing initialisation parameters to the invoked app is achieved by simply appending the switches or values to the application string as follows:

   lngVal = Shell(App.Path & "\myOtherApp.exe -formwidth:850 /ADMIN", 1)

These parameters can be interrogated using the Command function as discussed in the CommandLine article.

 

Top of Page

Legal Notice

Ken Howe 2011