Name Property

Purpose

Returns the name used in code to identify a form or Ocx control.

Syntax

$ = object.Name

object:Ocx Object

Description

The default name for new objects is the kind of object plus a unique integer. For example, the first new Form object is frm1, a new Command object is cmd1, and the third TextBox control you create on a form is txt3.

An object's Name property must start with a letter and can be a maximum of 40 characters. It can include numbers and underline (_) characters but can't include punctuation or spaces. Forms can't have the same name as another public variable. Although the Name property setting can be a keyword, property name, or the name of another object, this can create conflicts in your code.

Note   Although GFA-BASIC 32 often uses the Name property setting as the default value for the Caption and Text properties, changing one of these properties doesn't affect the others.

Example

Print Me.Name

Remarks

The names of from created with OpenW and Dialog are predefined as Win_n and Dlg_n respectively, where n is a number between 0 and 31. The name is introduced in the global variable list and is accessible throughout the program. These variable names can be used in accessing properties, methods, and events. For instance, Win_1.Name returns "Win_1". Windows created with a number greater than 31 don't declare global variable names implicitly and can only be accessed using Form(n).Name. However, there is no variable name introduced but their name still consists of "Win_n", where n is the window number.

OpenW 100

Print Form(100).Name            // Win_100

Do : Sleep : Until Me Is Nothing

 

Sub Form_Click(index%)

Print Me.Name, index%         // Win_100   100

EndSub

See Also

Form

{Created by Sjouke Hamstra; Last updated: 19/09/2016 by James Gaite}