Figure 2. Exploit the .NET Toolkit's Wrappers for InfoPath COM Objects.
The Microsoft.Office.Interop.InfoPath.SemiTrust namespace defines classes, interfaces, enums, and delegates for interoperability with InfoPath's COM objects. Delegates define the handlers for InfoPath's 13 events. The Application class shown here and the XDocument class are the most commonly used types in event handlers. Add Option Strict On to FormCode.vb and cast object variables to types defined by the namespace to avoid late binding and enable IntelliSense statement completion and parameter lists.