Visual Basic Reference
- Returns the name used in code to identify a form, control, or data access object. Read-only at run time.
- Returns or sets the name of a font object.
The object placeholder represents an object expression that evaluates to an object in the Applies To list. If object is omitted, the form associated with the active form module is assumed to be object.
The default name for new objects is the kind of object plus a unique integer. For example, the first new Form object is Form1, a new MDIForm object is MDIForm1, and the third TextBox control you create on a form is Text3.
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 object such as Clipboard, Screen, or App. Although the Name property setting can be a keyword, property name, or the name of another object, this can create conflicts in your code.
You can use a form's Name property with the Dim statement at run time to create other instances of the form. You can't have two forms with the same name at design time.
You can create an array of controls of the same type by setting the Name property to the same value. For example, when you set the name of all option buttons in a group to MyOpt, Visual Basic assigns unique values to the Index property of each control to distinguish it from others in the array. Two controls of different types can't share the same name.
Note Although Visual Basic often uses the Name property setting as the default value for the Caption, LinkTopic, and Text properties, changing one of these properties doesn't affect the others.
Changing the case of the Name property value for a Form or other module without otherwise changing the name itself, however, can cause a Conflicting names error message the next time the project containing the form or module is loaded. For example, changing Form1 to form1 will cause the error; changing Form1 to formX will not.
The error is caused by the way module names are stored within the project file the procedure for changing names within the project file isnt case sensitive, while the procedure for reading names on project load is.