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 />

Data Subtype Identification<br />

The Parser that is part of the <strong>VBScript</strong> Scripting Engine automatically defines a variable’s data subtype<br />

<strong>for</strong> you at runtime. However, there are times when the programmer may need to know the variable’s<br />

data subtype. To determine the specific data subtype used, <strong>VBScript</strong> you can use any of the three<br />

categories of functions to determine the data subtype:<br />

• The VarType(variable) function which returns a code based on the Variant data subtype used<br />

• Various IsXxxx(variable) functions which return boolean values indicating whether the variable<br />

is of a specific data subtype.<br />

• A TypeName(variable) function which returns a string based indicating the data subtype<br />

Variant Data Subtype Identification Functions<br />

Variant<br />

Function<br />

Description<br />

IsArray()<br />

IsDate()<br />

IsEmpty()<br />

IsNull()<br />

IsNumeric()<br />

Returns a Boolean value indicating whether a variable is an array<br />

Returns a Boolean value indicating whether an expression can be converted to a date<br />

Returns a Boolean value indicating whether a variable has been initialized.<br />

Returns a Boolean value that indicates whether an expression contains no valid data (Null).<br />

Returns a Boolean value indicating whether an expression can be evaluated as a number<br />

IsObject() Returns a Boolean value indicating whether an expression refers to a valid Automation<br />

object.<br />

TypeName() Returns a string that provides Variant subtype in<strong>for</strong>mation about a variable<br />

VarType() Returns a value indicating the subtype of a variable<br />

VarType() Function<br />

This function is similar to TypeName except that a numeric value, or ID, is returned that is used to<br />

identify the data subtype. This ID can then, as an example, be used in a flow control statement.<br />

VarType Constants (returned from the VarType() function)<br />

Constant Value Description<br />

vbEmpty 0 Empty (uninitialized)<br />

vbNull 1 Null (no valid data)<br />

vbInteger 2 Integer<br />

vbLong 3 Long Integer<br />

vbSingle 4 Single-precision floating-point number<br />

vbDouble 5 Double-precision floating-point number<br />

vbCurrency 6 Currency<br />

vbDate 7 Date<br />

vbString 8 String<br />

vbObject 9 Object<br />

vbError 10 Error<br />

vbBoolean 11 Boolean<br />

vbVariant 12 Variant (Used only with Arrays)<br />

vbDataObject 13 Data-access Object<br />

vbDecimal 14 Decimal<br />

vbByte 17 Byte<br />

vbArray 8192 Array<br />

Example:<br />

Myval = 23.3<br />

If VarType(Myval) = vbSingle Then<br />

Msgbox “MyVal is a Single Precision Floating Point Number”<br />

End If<br />

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

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

Saved successfully!

Ooh no, something went wrong!