Visual Basic naming rules
Use the following rules when you name procedures, constants, variables, and arguments in a Visual Basic module:
You must use a letter as the first character.
You can't use a space, period (.), exclamation mark (!), or the characters @, &, $, # in the name.
Name can't exceed 255 characters in length.
Generally, you shouldn't use any names that are the same as the function, statement, method, and intrinsic 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, statement, or 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 usingVBA.Left
.You can't repeat names within the same level of scope. For example, you can't declare two variables named
age
within the same procedure. However, you can declare a private variable namedage
and a procedure-level variable namedage
within the same module.
Note
Visual Basic isn't case-sensitive, but it preserves the capitalization in the statement where the name is declared.
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기