UserForms.FormCount Property

Applies to TestComplete 15.10, last modified on December 15, 2021

Description

The UserForms.FormCount property returns the total number of user forms that the current project contains. To obtain a form by its index, use the Form property.

Declaration

UserForms.FormCount

Read-Only Property Integer

Applies To

The property is applied to the following object:

Property Value

An integer value that means the total number of user forms in the current project.

Example

The following code snippet demonstrates how you can use the FormCount property:

JavaScript, JScript

function Test()
{

  var Count;
  // Determines the total amount of user forms in the project
  Count = UserForms.FormCount;

  // Checks if the project contains at least one user form …
  if (Count > 0)
    {
    Log.AppendFolder("The project contains the following user forms:");
    // …Iterates through the user forms and posts their names to the log
    for (var i = 0; i < Count; i++)
      Log.Message(UserForms.Form(i).Name);
    Log.PopLogFolder();
    }
  else
  Log.Message("The project does not contain any user forms.");
}

Python

def Test():
  # Determines the total amount of user forms in the project
  Count = UserForms.FormCount
  # Checks if the project contains at least one user form ...
  if Count > 0:
    Log.AppendFolder("The project contains the following user forms:")
    # Iterates through the user forms and posts their names to the log
    for i in range(0, Count):
      Log.Message(UserForms.Form[i].Name);
    Log.PopLogFolder()
  else:
    Log.Message("The project does not contain any user forms.")

VBScript

Sub Test

  Dim Count
  ' Determines the total amount of user forms in the project
  Count = UserForms.FormCount

  ' Checks if the project contains at least one user form …
  If Count > 0 Then
    Log.AppendFolder("The project contains the following user forms:")
    ' …Iterates through the user forms and posts their names to the log
    For i = 0 To Count -1
      Log.Message(UserForms.Form(i).Name)
    Next
    Log.PopLogFolder
  Else
  Log.Message("The project does not contain any user forms.")
  End If
End Sub

DelphiScript

procedure Test();
var Count, i;
begin

  // Determines the total amount of user forms in the project
  Count := UserForms.FormCount;

  // Checks if the project contains at least one user form …
  if Count > 0 then
    begin
    Log.AppendFolder('The project contains the following user forms:');
    // …Iterates through the user forms and posts their names to the log
    for i := 0 to Count - 1 do
      Log.Message(UserForms.Form(i).Name);
    Log.PopLogFolder;
    end
  else
  Log.Message('The project does not contain any user forms.');
end;

C++Script, C#Script

function Test()
{

  var Count;
  // Determines the total amount of user forms in the project
  Count = UserForms["FormCount"];

  // Checks if the project contains at least one user form …
  if (Count > 0)
    {
    Log["AppendFolder"]("The project contains the following user forms:");
    // …Iterates through the user forms and posts their names to the log
    for (var i = 0; i < Count; i++)
      Log["Message"](UserForms.Form(i).Name);
    Log["PopLogFolder"]();
    }
  else
  Log.Message("The project does not contain any user forms.");
}

See Also

Form Property
FormByName Property

Highlight search results