How to See Forms Running in VB6

Checking which forms are currently running in your Visual Basic 6.0 (VB6) program is helpful when you need to know whether a form is already running so you don't load it again. A form is the main object of Visual Basic and contains all the components and controls for your program. VB6 features a forms collection that contains all the currently running forms. Loop through the forms collection and check each form's name to see which are running.

Instructions

    • 1

      Open your Visual Basic 6.0 file in an editor such as Microsoft Visual Studio 6.0.

    • 2

      Display the names of all the currently loaded forms by looping through the "Forms" collection. Add the following code in your function:

      Dim f as Form

      For each f in Forms

      MsgBox f.Name

      Next f

      A "MsgBox" will pop up and display the name of each "Form" loaded.

    • 3

      Display the name of a specific form if it's loaded by looping through the "Forms" collection. Add the following code in your function:

      Dim f as Form

      For each f in Forms

      If f.Name = "Form2" Then

      MsgBox f.Name

      End If

      Next f

      A "MsgBox" will pop up if the form with the name "Form2" is currently loaded.

    • 4

      Save the Visual Basic 6.0 file, compile and run the program to see what forms are running.

Related Searches:

References

Comments

Related Ads

Featured