Cross-referencing is a technique where Project Analyzer resolves the meaning of every word of code and records the location of every call, variable use and so on.

A reference has a source location (line in source code), a target location (such as procedure, variable or control) and type (read, write, call, event raise etc.). A reference usually forms a file dependency between the source and the target files.

"References to" window

References to window

To work out where a variable, constant, procedure, or other code construct is referenced in your code, bring up the References to window. You do it by right-clicking an item in the main screen. You can right-click:

You also get to this window via the References button References button in the Listings windows and Constants and Enums window.

Double-click a line to view the code location in hypertext. Click the report button to generate a report of the references.

Suggested uses for "References to" window

Determine use of functions
To see how a certain function is used in your project, right-click its name and select References. Press the Source report toolbar button to get a list of the call locations.
Determine variable reads and writes
To see how a certain variable is used, right-click its name and select References. Watch the read and write references.
.NET migration to-do list
References are useful when you plan to upgrade old code to VB.NET. You can review the use of each function that is either unsupported or problematic in VB.NET. For example, you list how AscB() is used, as this byte-function doesn't exist in VB.NET. To view built-in functions such as AscB, you need to enable COM analysis (feature requires Enterprise Edition) for the default run-time files msvbvm60.dll and vb6.olb.
Verify use of custom exception classes
To see how a custom exception is thrown and handled, right-click the exception class name and select References. A reference of type "Instantiate object" usually indicates a Throw statement. A reference of type "Data" usually indicates a Catch block that catches this specific exception class. If an exception class is never instantiated, it means that type of exception is never thrown. It is semi-dead code.

"References" window

Open this window by selecting References in the View menu.

References window

This window lets you list references in several ways:

Set the Source and Target files and click Search to display a list of references between these files. If the Target is <Self>, references within the file itself are displayed. The Target <All> indicates that all references in the source file are displayed. Double-click a line to view the code location in hypertext.

You can sort the references by clicking the column headers. Press the report buttons or Ctrl+R to get a listing of all the references currently displayed.

Suggested uses for "References" window

How other files use file X?
Select X as the target file and <Any other file> as the source.
ByRef review
Review ByRef passing to procedures that change the value of their parameter(s). Select "Pass ByRef (possible write)" as the reference type.
Determine the use of late binding
Select "Call late-bound" as the reference type.
Object instantiation report
Select "Instantiate object" as the reference type.
List objects instantiated in file X
Select "Instantiate" as the reference type, X as the source file and <All> as the target.
Quick inheritance report or implements report
Select "Inherits" or "Implements" as the reference type.
Determine dynamic event handling
Select "AddHandler" as the reference type. You could also list the "RemoveHandler" calls.
List event handlers
Select "Handles" as the reference type. VB.NET only. AddHandler references must be listed separately.
List handlers of class X events
Select "Handles" as the reference type, X as the target file and <All> as the source.
ReDim report to list dynamic array allocation
Select "Allocate" as the reference type.
Form.Show locations list
Select "Show" as the reference type.
Data storage report
Select "Write" as the reference type and the appropriate Source or Target file that you're interested in. You may also need to list "Write+Read", "Read+Write", "Write handle" and "Clear" to get a complete listing.
Overrides report
List the calls that class X's Overrides procedures may respond to: Select "Call Overrides" as the reference type, X as the target and <All> as the source.

Reference types

Data references Explanation
Read Read a variable, user-defined type field, constant or enum constant.
Read (Nothing) Read an object variable or field to determine if it is Nothing.
Example: If x Is Nothing Then
Write Write a value to a variable or user-defined type field.
Write+Read First write to a variable, then read it in a single statement.
Example: For x=1 To...
Read+Write First read a variable, then write to it in a single statement.
Example: x+=1
Instantiate object Instantiate an object of a class.
Instantiate Assign a newly instantiated object to a variable.
Examples: Set x=New Class, Set x=CreateObject(...)
Allocate Allocate a dynamic array with ReDim.
Clear Clear a variable or an array. This is the equivalent of a Write with a "nothing" value.
Examples: Set x=Nothing, Erase x
Write handle Write newly created API resource handle to a variable. This is a special case of a Write.
Release Read variable and release the API resource handle contained in it. This should be paired with Write handle.
Pass ByRef (possible write) Pass a variable by reference to another procedure. The target procedure may modify the variable.
Pass ByRef (read only) Pass a variable by reference to another procedure. The target procedure does not modify the variable.
Return value Set the function return value.
Address Take the address of a procedure or a variable via AddressOf, StrPtr, VarPtr or ObjPtr.
Call references Explanation
Call Call a procedure. Property read and write are shown as a Call to the appropriate accessor (Set/Let/Get).
Call late-bound Call a procedure, late-bound. This call may (or may not) execute at run-time. It depends on the actual contents of the related late-bound object variable.
Call Overloads A call that is subject to Overloads, or Overrides Overloads, in that the call may go to several methods based on the data type of the parameter(s). (VB.NET)
Call Overrides A call to an Overrides method. The call may go to a method in several classes based on what class the object represents at run-time. (VB.NET)
Raise Raise an Event via RaiseEvent.
Trigger Trigger an event (Initialize event is triggered through As New).
Handles Handle an Event with the Handles keyword. (VB.NET)
AddHandler from/to AddHandler statement adds a handler for an event. The execution goes like this: event --> handler. From=event, to=handler. (VB.NET)
Show Show a form via the Show or ShowDialog method.
Other references Explanation
Implements Implements statement or keyword is used to implement an interface or its member.
Inherits A class Inherits another. (VB.NET)
Data Target is being used as a data type.
Example: As MyClass.
Use Any other use, such as the use of a module name.

Special: A structured write reference such as x.y=3 is treated as follows:

ReferencesHappens when
read x, write yx is an object and y is its member variable
write x, write yx is a variable defined "As MyType", y is a field in Type MyType (classic VB)
read x, write yx is a variable defined "As MyStructure", y is a field in Structure MyStructure (VB.NET)

See also

Call trees
Project Graph
Enterprise Diagrams

©Aivosto Oy - Project Analyzer Help Contents