Senin, 24 Februari 2025

Visual Basic Naming Conventions And Visual Basic Naming Rules

Visual Basic Naming Rules

Use the following rules when you name procedures, constants, variables, and arguments in a Visual Basic module:

  1. You must use a letter as the first character or an underscore.
  2. You can't use a space, period (.), exclamation mark (!), or the characters at symbol (@), Ampersand (&), Dollar sign ($),  number sign (#) in the name.
  3. Name can't exceed 255 characters in length.
  4. Generally, you shouldn't use any names that are the same as the (intrinsic or default or built-in) function, statement, method, and (intrinsic or default or built-in) constant names used in Visual Basic or by the host application. Otherwise you end up shadowing the same keywords in the language. To use an intrinsic language function, statement, or method that conflicts with an assigned name, you must explicitly identify it. Precede the intrinsic function, intrinsic statement, or intrinsic method name with the name of the associated type library. For example, if you have a variable called Left, you can only invoke the Left function by using VBA.Left.
  5. Avoid using names in an inner scope that are the same as names in an outer scope. Errors can result if the wrong variable is accessed. If a conflict occurs between a variable and the keyword of the same name, you must identify the keyword by preceding it with the appropriate type library. For example, if you have a variable called Date, you can use the intrinsic Date function only by calling DateTime.Date.

Visual Basic Naming Conventions

The following suggestions apply to naming.

  1. Begin each separate word in a name with a capital letter, as in FindLastRecord and RedrawMyForm.
  2. Begin function and method names with a verb, as in InitNameArray or CloseDialog.
  3. Begin class, structure, module, and property names with a noun, as in EmployeeName or CarAccessory.



Next Visual Basic 6 Variable Prefixes >


Tidak ada komentar:

Posting Komentar

Various Other Posts