Getting information on how the VB compiler handles various things would be helpful to know whether it is more efficient to code in a certain way. For example a question of late is:
How the compiler handles string memory storage.
I can see three possible alternatives.
1) The compiler stores all strings in a central memory location and just has a pointer reference stored on either the heap or stack.
2) The compiler uses where the string is declared to determine where the string is placed in memory.
In the simplest case if the string is declared locally (Dim strPrompt As String) and then assigned in the local procedure to the local variable, the entire string logically would be put in stack memory.
3) The compiler uses the variable to which the string is assigned to determine where it is stored (heap or stack). In this case, if no local variable is declared, and the string is assigned to a global variable, does the compiler consider the string to belong to the local procedure or does the assignment "rule" ?
If the assignment does Not rule, then the string logically would belong to the local procedure and the assignment to the global variable would cause either a copy of the string to also be stored on the heap (per your above) or pointer reference copied to the heap?
Are you talking about strings used by an application written in VB.NET?
In .NET, strings are represented by System.String object, which is a reference type and is stored on the heap. Whenever compiler runs into a string literal, it emits code that allocates new System.String object and stores the reference to the object in the target variable, field, etc.
VB.NET Compiler Dev Team.