VS VB6 VBA
are variables used in code templates, exception / error handlers, headers, etc. whose values are assigned automatically by when the code template is inserted into the code file (on the contrary to , whose values are asked to the user through a dialog window).
Predefined variables are created using the button, which shows this dialog window, where you select the predefined variable:

The predefined variables provided by to be used in templates are specified below. Note that not all the predefined variables are supported in every kind of template or IDE:
- : the text currently selected in the document. This variable is useful to enclose the selected text with some code above and below. For example, to add an exception / error handler to selected code.
- : the prefix that the language of the document uses to comment lines. For example, C# uses the // prefix while VB.NET / VB / VBA uses the ' prefix. This variable is useful to create templates with comments that can be used by documents in several languages.
- : the prefix that the .NET language of the document uses for XML comments. For example, C# uses the /// prefix while VB.NET uses the ''' prefix. This variable is useful to create templates with XML comments that can be used by documents in several .NET languages.
- : a new generated Guid.
- : the user who is inserting the template. You can customize in the window, tab, section, whether you want to use the username or a specific username.
- : the name of your company. You can customize its value in the window, tab, section.
- : for Visual Studio projects, this is the value of the attribute specified in the file of the project, and it represents the version of the assembly. In .NET, assemblies have an assembly file version and an assembly version.
- : for Visual Studio projects, this is the value of the attribute specified in the file of the project, and it represents the version of the file of assembly (not to be confused with the version of the assembly).
- : the current date. You can customize the format in the window, tab, section.
- : the current time. The format is always "HH:mm" and can not be customized.
- : the current year (useful for copyrights). The format is always "yyyy" and can not be customized.
- : this variable is not replaced by an actual value but it allows you to specify where the text cursor (the caret) should be positioned after the template is inserted in the document.
- or : the name of the solution or project group (the file name without the extension).
- or : the name without path of the file of the solution or project group.
- or : the name with path of the file of the solution or project group.
- or : the path of the folder of the solution or project group.
- : the name of the project of the document where the template is being inserted (for Visual Studio it's the file name without the extension).
- : the name without path of the file of the project of the document where the template is being inserted.
- : the name with path of the file of the project of the document where the template is being inserted.
- : the extension of the file of the project of the document where the template is being inserted.
- : the folder of the project of the document where the template is being inserted.
- : the name without path of the file of the document where the template is being inserted.
- : the name with path of the file of the document where the template is being inserted.
- : the extension of the file of the document where the template is being inserted.
- : the folder of the file of the document where the template is being inserted.
- : the kind of the file. For example, for .NET: "Form", "UserControl", "Code", etc. For VB/VBA: "Class", "Form", "Module", "Class Module", "UserControl", "UserDocument", "Property Page", "Designer", etc.
- : the full name (with namespace or library name) of the code element where the template is being inserted. For example, "Vehicles.Car".
- : the name (without namespace) of the code element where the template is being inserted. For example, "Car".
- : the declaration of the code element where the template is being inserted. For example, "public int f1()".
- : the description of the code element where the template is being inserted. For example, "Class", "Namespace", etc.
- : the keyword for the kind of the code element where the template is being inserted. For example, "struct" for C#, "Structure" for VB.NET, "Type" for VB, etc.
- : the keyword for the visibility of the code element. For example, "Public", "Private", etc.
- : the body of the method where the template is being inserted, including method constants and variables. This variable is useful to insert custom code at the start / end of a method, or for exception / error handlers.
- : the body of the method where the template is being inserted, excluding method constants and variables. This variable is only available for VB6/VBA and is useful for error handlers. In VB, variable declarations that create instances with the New operator (ex: Dim myCar As New Car) cannot execute code (instances are created when the variable is actually used) and therefore can be excluded from the error handler. In .NET they can execute code since the instance is created when the variable is declared.
- : the list of handled events (after the "Handles" clause of the method declaration).
- : delimiter of the begin of a section that will be used for information about the return type of a method. It is useful to include that information inside a section because the whole section is deleted if the method doesn't return a value ("void" in C#, "Sub" in Visual Basic), so you can share the same header for methods that return values and methods that don't.
- : delimiter of the end of a section that will be used for information about the return type of a method. It is used along with the previous one.
- : the name of the type that the method returns, using the .NET Framework name. For example, "Int32".
- : the full name of the type that the method returns. For example, "System.Int32".
- : the alias in the .NET language of the document for the type that the method returns. For example, "int" in the case of C# or "Integer" in the case of VB.NET.
- : the prefix defined in the window, tab, section (see Type Tags Options) for the type that the method returns.
- : the kind of property, such as "Get", "Set", "Let" for Visual Basic and "get" or "set" for C#.
- : delimiter of the begin of the section that will be repeated for each parameter.
- : delimiter of the end of the section that will be repeated for each parameter. It is used along with the previous one.
- : the name of the parameter of the method, delegate, etc.. One line is generated for each parameter unless the and predefined variables are used.
- : the full name of the type of the parameter. For example, "System.Int32".
- : the name of the type of the parameter, using the .NET Framework name. For example, "Int32".
- : the alias in the .NET language of the document for the type of the parameter. For example, "int" in the case of C# or "Integer" in the case of VB.NET.
- : the modifiers of the parameter. For example, "ref", "out", etc. for C# or "ByVal", "ByRef", "Optional", etc. for VB.NET.
- : the default value of an optional parameter.
- : since normally one line is generated for each parameter, this variable allows you to align the descriptions of the parameters after the names.
- : the comma character "," if the parameter is not the last one, or the empty character "" if it is the last one. This variable is typically used to build a comma-separated list of parameters in a single line.
- : the space character " " if the parameter is not the last one, or the empty character "" if it is the last one. This variable is typically used to build a comma-separated list of parameters in a single line.
- : delimiter of the begin of the section that will be repeated for each type parameter of a generic declaration.
- : delimiter of the end of the section that will be repeated for each type parameter of a generic declaration. It is used along with the previous one.
- : the name of each type parameter of a generic declaration. One line is generated for each parameter unless the and predefined variables are used.
- : since normally one line is generated for each generic type parameter, this variable allows you to align the descriptions of the generic type parameters after the names.
- : the comma character "," if the generic type parameter is not the last one, or the empty character "" if it is the last one. This variable is typically used to build a comma-separated list of generic type parameters in a single line.
- : the space character " " if the generic type parameter is not the last one, or the empty character "" if it is the last one. This variable is typically used to build a comma-separated list of generic type parameters in a single line.
- : the custom tag of the control defined in the Control Tag Options. For example, "btn" for the System.Windows.Forms.Button control.
- : the default tag of a control, which is the type name of the control. For example, "Button" for the System.Windows.Forms.Button control.
- : the tag of the type defined in the Type Tags Options.
- : the tag of the type defined in the Type Tags Options in upper case (useful if your constants use upper case and include a type tag).
- : the name of the type. For example, "Car".
- : the name of the type with lower initial letter. For example, "car".
- : the name of the base type.
- : the tag for arrays defined in the Type Tags Options.
- : the name of the parent code element. For example, the namespace name for a class.
The New Method / Property Assistant Options allows you to use the following predefined variables:
- : the name of the property.
- : the name of the property. with lower initial letter. This is useful if you want to generate a field named "_age" for a property named "Age".
- : the name of the method.
- : the name of the method. with lower initial letter. This is useful if you want to generate a result variable named "getBalanceResult" for a method named "GetBalance".
The Replace Text feature of allows you to use the following predefined variables. This can be useful in composing the replacement text:
- : the text that has been found according to the search criteria.
- : the whole line where the text has been found.
- : the text in the line before the found text.
- : the text in the line after the found text.
Converting MZ-Tools 3.0 predefined variables
If the .ini options file of MZ-Tools 3.0 is present on the system when is loaded for the first time, you should get a prompt to import the options (code templates, headers, error handler, etc.), which also converts the predefined variables from the old version to the new one. If you need to convert them by hand, the equivalence is the following:
|
|
{PROJECT_GROUP_FILENAME_WITH_PATH}
|
$P[PROJECT_GROUP_FILENAME_WITH_PATH]
|
{PROJECT_NAME}
|
$P[PROJECT_NAME]
|
{PROJECT_FILENAME}
|
$P[PROJECT_FILENAME]
|
{PROJECT_FILENAME_WITH_PATH}
|
$P[PROJECT_FILENAME_WITH_PATH]
|
{MODULE_NAME}
|
$P[PARENT_CODE_ELEMENT_NAME]
|
{MODULE_TYPE}
|
$P[PROJECT_ITEM_KIND]
|
{MODULE_FILENAME}
|
$P[PROJECT_ITEM_FILENAME]
|
{MODULE_FILENAME_WITH_PATH}
|
$P[PROJECT_ITEM_FILENAME_WITH_PATH]
|
{PROCEDURE_BODY}
|
$P[METHOD_BODY_EXCLUDING_DECLARATIONS]
|
{PROCEDURE_NAME}
|
$P[CODE_ELEMENT_NAME]
|
{PROCEDURE_NAME_CONTROL_NAME}
|
$P[CODE_ELEMENT_NAME]
|
{PROCEDURE_TYPE}
|
$P[CODE_ELEMENT_KIND_KEYWORD]
|
{FUNCTION_RETURN_TYPE_NAME}
|
$P[METHOD_RETURN_TYPE_NAME]
|
{FUNCTION_RETURN_TYPE_PREFIX}
|
$P[METHOD_RETURN_TYPE_PREFIX]
|
{AUTHOR}
|
$P[AUTHOR]
|
{DATE}
|
$P[DATE]
|
{TIME}
|
$P[TIME]
|
{I}
|
$P[I]
|
See Also:
User-defined variables
|