UserForm.Name Property

Applies to TestComplete 15.42, last modified on September 08, 2022

Description

The Name property returns the form name. This is the same value that identifies the form under the User Forms node in the Project Explorer panel. The value of the Name property is used to access the form from scripts, directly via the UserForms object or via the UserForms.FormByName property:

JavaScript, JScript

var form;
// The following two lines are equivalent
form = UserForms.MyForm;
form = UserForms.FormByName("MyForm");

Python

# The following two lines are equivalent
form = UserForms.MyForm
form = UserForms.FormByName["MyForm"]

VBScript

' The following two lines are equivalent
Set form = UserForms.MyForm
Set form = UserForms.FormByName("MyForm")

DelphiScript

var form : OleVariant;
...
// The following two lines are equivalent
form := UserForms.MyForm;
form := UserForms.FormByName['MyForm'];

C++Script, C#Script

var form;
// The following two lines are equivalent
form = UserForms["MyForm"];
form = UserForms.FormByName["MyForm"];

Declaration

UserForm.Name

Read-Only Property Text

Applies To

The property is applied to the following object:

Property Value

The string that contains the form name.

Remarks

To get or set the text displayed in the form title bar, use the Caption property.

Example

The following example demonstrates how you can use the Name property to obtain the form name:

JavaScript, JScript

function Test()
{

  var Count, UserFormName;

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

  // Iterates through the user forms
  for (var i = 0; i < Count; i++)
    {
    // Obtains the name of each user form in the project
    UserFormName = UserForms.Form(i).Name;
    // Posts the form’s name to the log
    Log.Message(UserFormName);
    }

}

Python

def Test():
  # Obtains the total amount of user forms in the project
  Count = UserForms.FormCount
  # Iterates through the user forms
  for i in range(0, Count):
    # Obtains the name of each user form in the project
    UserFormName = UserForms.Form[i].Name
    # Posts the form's name to the log
    Log.Message(UserFormName)

VBScript

Sub Test

  Dim Count, UserFormName

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

  ' Iterates through the user forms
  For i = 0 To Count - 1
    ' Obtains the name of each user form in the project
    UserFormName = UserForms.Form(i).Name
    ' Posts the form’s name to the log
    Log.Message(UserFormName)
  Next

End Sub

DelphiScript

procedure Test();
var Count, UserFormName, i;
begin

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

  // Iterates through the user forms
  for i := 0 to Count -1 do
    begin
    // Obtains the name of each user form in the project
    UserFormName := UserForms.Form(i).Name;
    // Posts the form’s name to the log
    Log.Message(UserFormName);
    end;

end;

C++Script, C#Script

function Test()
{

  var Count, UserFormName;

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

  // Iterates through the user forms
  for (var i = 0; i < Count; i++)
    {
    // Obtains the name of each user form in the project
    UserFormName = UserForms["Form"](i)["Name"];
    // Posts the form’s name to the log
    Log["Message"](UserFormName);
    }

}

See Also

Caption Property

Highlight search results