Module: VB_Application in Category Microsoft Visual Basic 6 : Application Techniques from Total Visual SourceBook

Routines for working with modules and the IDE in VB6.

This includes handling chores such as ensuring that all forms in the application are closed before exiting, and testing the open status of forms in your and other applications.

Procedure Name Type Description
(Declarations) Declarations Declarations and private variables for the modVB_Application module.
AnyModulesOpen Procedure Determine if any modules are open in the VBE.
CloseAllVBEModules Procedure Close all open modules in VBE.
CloseForms Procedure Close all forms in the application. The calling form is closed last. If you want to close your application without using the 'END' statement, and you have many forms which may or may not be open, it may be difficult to completely close an application. The application does not stop until all forms are unloaded.
CloseVBEWindow Procedure Close the VBE window.
GetOpenModuleCount Procedure Get the number of modules open in the VBE.
IsAppRunningTitled Procedure Check to see if there is an application running with the specified caption. This function finds exact matches only. For example, if you have a copy of Notepad running with no document loaded, you would need to search on the value "Untitled - Notepad", not just "Notepad".
IsCurrentProjectSaved Procedure Determine if the current VBE project is in a saved state.
IsFormLoaded Procedure Test to see whether the default instance of a form is loaded. If the default instance of a form is loaded, it is in the Forms collection. This function tests to see whether a form of the specified name is in the collection.
IsModuleSaved Procedure Determine if the current module is in a saved state in the VBE.
RunningFromIDE Procedure Determine if the program is currently running from the VB6 IDE or from the compiled executable. Requires an app with at least one form.
' Example of modVB_Application
'
' To try these examples, do the following:
' 1. Create a new form
' 2. Create a command button 'cmdTest'
' 3. Create a command button 'cmdExit'
' 4. Paste all the code from this example to the new form's module.
'    Press the cmdTest and cmdExit buttons to test the procedures.

Private Sub cmdTest_Click()

  ' Example of IsAppRunningTitled
  ' Try running the CALC.EXE application to test this procedure
  If IsAppRunningTitled("Calculator") = True Then
    MsgBox "Calculator is running"
  Else
    MsgBox "Calculator is not running"
  End If

  ' Example of IsFormLoaded
  ' To test this function, create a form called "Customers" and test with the form both loaded and unloaded
  If IsFormLoaded("Customers") = True Then
    MsgBox "Customers form is open"
  Else
    MsgBox "Customers form is not open"
  End If

  ' Example of RunningFromIDE
  If RunningFromIDE() = True Then
    MsgBox "The app is running from the IDE"
  Else
    MsgBox "The app is running from the executable"
  End If

End Sub

Private Sub cmdExit_Click()
  ' Example of CloseForms
  ' Close all forms in the application first, and then close the current form, which causes the application to stop

  CloseForms Me

End Sub

Total Visual SourceBook The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!

Additional Resources

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!


View all FMS products for Microsoft Access All Our Microsoft Access Products

Reviews

Reader Choice Award for MS Access Source Code Library
Reader Choice

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

SourceBook Info

Additional Info

Question

 

 

Free Product Catalog from FMS