18.01.2013 Views

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong> <strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong><br />

Other extrinsic objects include ActiveX Objects, ADO.NET, and OLE Automation Objects such as<br />

Microsoft Office applications and components. These objects use a different statement <strong>for</strong>mat <strong>for</strong><br />

instantiation. They use either the CreateObject or GetObject functions. For example:<br />

Set cObj = CreateObject(“ADODB.Connection”)<br />

Set xlObj = CreateObject(“Excel.Application”)<br />

Set xlBook = GetObject(“C:\Test.XLS”)<br />

The difference between CreateObject and GetObject is that CreateObject is used to create an interface<br />

to a new instance of an application (or object) while the GetObject is used with an application that is<br />

already loaded.<br />

To declare constants, you use the Const statement. An example is:<br />

Const mySetting = 100<br />

As previously discussed, constants have scope. The scope of a constant can be modified by adding<br />

either the keyword Public or Private in front of the Const declaration.<br />

Key Notes:<br />

• All Arrays in <strong>VBScript</strong> are zero-based, meaning that the array myArray(10) really has 11<br />

elements. Unlike VB or VBA, all arrays in <strong>VBScript</strong> are zero-based.<br />

• Arrays, Objects (except implicit Err Object) and Named Constants must be declared.<br />

• Using Option Explicit <strong>for</strong>ces all variables to be declared. This helps prevent runtime<br />

errors due to mis-typing.<br />

96 <strong>InduSoft</strong>, Ltd.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!