Imports system namespaces

The namespaces are at the top of the template. They are part of the default record. These namespaces enable the VB Script to use various .NET classes.

Namespaces can be added or removed from the script. For example, you can remove imports Systems.Diagnostics if you do not require tracing.

  • Use Imports System for all. It has some useful things in it, such as exception class (i.e., error handling) Array, DBNull.
  • Use System.Diagnostics for tracing.
  • Use System.XML if your script includes XML documents.
  • System.Data can return the ADO.Net Dataset. This is used by ObjMethod commands, required for search results reports, for example.
  • Use System.Text.RegularExpressions for string manipulations. Use regular expressions for search and replace on string values.
  • When you use System.Text, use the Microsoft StringBuilder class as a performance-oriented alternative to simple string concatenation. This enables you to reserve the memory for the resultant string.
  • Use System.Net if you plan on talking to other networked systems. For example, calling a WebService on another product such as making an HTTP call from the Optiva workflow to WebReports to print a report.
  • System.Configuration enables the script to read .Net configuration files like Web.config.
  • System.Collections includes the Hashtable definitions and ArrayLists which are both useful for building and checking a list of objects.

In general, if you declare a name space at the top of the script, you do not have to add prefixes in the code. For example, extended math commands live in the System.Math namespace. With it declared, the script is:


Dim tpval as Double = Round(3.14159*2)

Otherwise, without a declaration, it is:


Dim tpval as Double = Math.Round((3.14159*2)

See the MSDN .NET Framework library.