Forms Property (App)

Purpose

Returns a Forms collection, which is a collection whose elements represent each loaded form in an application.

Syntax

App.Forms

Description

The collection includes the application's MDI form, MDI child forms, and non-MDI forms. The Forms collection has a one method, Item, and a single property, Count, that specifies the number of elements in the collection.

Item(Index As Variant) is the default and returns a Form object.

Example

Debug.Show

OpenW 1

OpenW 33

Trace App.Forms.Count

Trace App.Forms(1).Name

Trace App.Forms.Item(2).Name

Trace App.Forms.Item(2).Caption

CloseW 1

CloseW 33

Remarks

You can also use For Each to enumerate over all forms.

Dim f As Form, n As Int

For n = 1 To 15 : OpenW Hidden n : Me.Caption = "Window " & n : Next n

Debug.Show

For Each f In App.Forms

Trace f.Name

Trace f.Caption

Next

For n = 1 To 15 : CloseW n : Next n

See Also

App, Controls

{Created by Sjouke Hamstra; Last updated: 07/10/2014 by James Gaite}