Class ProgramEntryPoint
Where a program of a project starts: the procedure a run of the project runs (Of(ProjectBuild?, IEnumerable<(VBModuleSymbol Module, IEnumerable<VBTypeMemberSymbol> Members)>)).
public static class ProgramEntryPoint
- Inheritance
-
ProgramEntryPoint
- Inherited Members
Remarks
MS-VBAL says nothing of a program's start: a VBA project is code a host calls into. A project that is a program has one entry point, as a VB6 project's
startup object is Sub Main: a Sub named Name, in a standard module, that the rest of the project can call - Public or
Global, or written with no scope, which is Public (MS-VBAL §5.3.1.1) - and that takes no argument, or takes what it is
given as one ParamArray: Sub Main(), or Sub Main(ParamArray Args()). A class or a document has no entry point: running one runs no
program.
The procedure is judged as the runtime session defined it, which is the procedure a run runs: of a declaration whose header is written once in each
branch of a #If block, the header of the live branch under the project's constants (MS-VBAL §3.4), and of a declaration written
only in dead branches, nothing, since it is not defined.
Fields
Name
The name of the procedure a program starts with when nothing names another.
public const string Name = "Main"
Field Value
Methods
IsDeclaredBy(VBModuleSymbol, IEnumerable<VBTypeMemberSymbol>, string)
Whether a module declares a procedure a program can start with.
public static bool IsDeclaredBy(VBModuleSymbol module, IEnumerable<VBTypeMemberSymbol> members, string name = "Main")
Parameters
moduleVBModuleSymbolThe module.
membersIEnumerable<VBTypeMemberSymbol>The members the runtime session defined for the module.
namestringThe name of the procedure; Name unless the run names another. VBA's names are compared without regard to case.
Returns
IsEntryPoint(VBTypeMemberSymbol, string)
Whether a member is a procedure a program can start with: a Sub of that name that the project can call, and that takes no argument or one
ParamArray.
public static bool IsEntryPoint(VBTypeMemberSymbol member, string name = "Main")
Parameters
memberVBTypeMemberSymbolThe member, as the runtime session defined it.
namestringThe name of the procedure; Name unless the run names another. VBA's names are compared without regard to case.
Returns
Remarks
A Declare Sub is not one: it is a procedure of a library, not of the module's code.
Of(ProjectBuild?, IEnumerable<(VBModuleSymbol Module, IEnumerable<VBTypeMemberSymbol> Members)>)
The entry point of a project: the procedure its build section names (EntryPoint), or else the Name
procedure of the one standard module that declares one.
public static ProgramEntryPointResolution Of(ProjectBuild? build, IEnumerable<(VBModuleSymbol Module, IEnumerable<VBTypeMemberSymbol> Members)> modules)
Parameters
buildProjectBuildThe project's
buildsection (Build); null for a project file that has none.modulesIEnumerable<(VBModuleSymbol Module, IEnumerable<VBTypeMemberSymbol> Members)>The project's modules, in the order a refusal names them, each with the members the runtime session defined for it.
Returns
- ProgramEntryPointResolution
The module and procedure the program starts at, or why the project has none (Refusal).
Remarks
An entry point named Module.Procedure is looked for in that module only, and one named Procedure in every standard module. Either way, a
procedure is one only when IsEntryPoint(VBTypeMemberSymbol, string) says so, in a standard module (IsDeclaredBy(VBModuleSymbol, IEnumerable<VBTypeMemberSymbol>, string)); names are compared without regard to
case. A module that is not a standard module is passed over.
A library has no entry point (Library): it is refused whatever its modules declare.