VBSCRIPT OTHER FUNCTIONS

Other Functions:

1.       Create Object-creates an object of a specified type.
Syntax: CreateObject(servername.typename[,location])
Servername-Required. The name of the application that provides the object
typename-Required. The type/class of the object
location-Optional. Where to create the object
2.       Eval-evaluates an expression, like a function, and returns the result.
Syntax-Eval(expression)
Example-function myFunction()
response.write("Hello world")
end function

eval("myFunction()")
Output-Hello world
3.       IsEmpty-returns a Boolean value that indicates whether a specified variable has been initialized or not. It returns true if the variable is uninitialized; otherwise, it returns False.
Syntax: IsEmpty(expression)
Example: Dim x
         response.write(IsEmpty(x) & "<br />")
         x=10
        response.write(IsEmpty(x) & "<br />")
        x=Empty
        response.write(IsEmpty(x) & "<br />")
        x=Null
        response.write(IsEmpty(x))
Output: True
        False
        True
        False
4.       IsNull-returns a Boolean value that indicates whether a specified expression contains no valid data (Null). It returns True if expression is Null; otherwise, it returns False.
Syntax: IsNull(expression)
Example: Dim x
response.write(IsNull(x) & "<br />")
x=10
response.write(IsNull(x) & "<br />")
x=Empty
response.write(IsNull(x) & "<br />")
x=Null
response.write(IsNull(x))
Output:
False
False
False
True
5.       IsNumeric-returns a Boolean value that indicates whether a specified expression can be evaluated as a number. It returns True if the expression is recognized as a number; otherwise, it returns False.
Syntax: IsNumeric(expression)
Example:
Dim x
x=10
response.write(IsNumeric(x) & "<br />")
x=Empty
response.write(IsNumeric(x) & "<br />")
x=Null
response.write(IsNumeric(x) & "<br />")
x="10"
response.write(IsNumeric(x) & "<br />")
x="911 Help"
response.write(IsNumeric(x))
Output:
True
True
False
True
False
6.       Round-rounds a number.
Syntax: Round(expression[,numdecimalplaces])
Expression-Required. The numeric expression to be rounded
Numdecimalplaces-Optional. Specifies how many places to the right of the decimal are included in the rounding. Default is 0
Example:
response.write(Round(24.13278) & "<br />")
response.write(Round(24.75122))
Output:
24
25
7.       TypeName-returns the subtype of a specified variable.
The TypeName function can return one of the following  values:Byte,Integer,Long,Single,Double,Currency,Decimal,Date,String,
Boolean,Empty,Null,<object type> ,Object,Unknown,Nothing,Error

Syntax: TypeName(varname)
Example:
x="Hello World!"
response.write(TypeName(x) & "<br />")
Output:
String
8.       VarType-returns a value that indicates the subtype of a specified variable.
The VarType function can return one of the following values:
  • 0 = vbEmpty - Indicates Empty (uninitialized)
  • 1 = vbNull - Indicates Null (no valid data)
  • 2 = vbInteger - Indicates an integer
  • 3 = vbLong - Indicates a long integer
  • 4 = vbSingle - Indicates a single-precision floating-point number
  • 5 = vbDouble - Indicates a double-precision floating-point number
  • 6 = vbCurrency - Indicates a currency
  • 7 = vbDate - Indicates a date
  • 8 = vbString - Indicates a string
  • 9 = vbObject - Indicates an automation object
  • 10 = vbError - Indicates an error
  • 11 = vbBoolean - Indicates a boolean
  • 12 = vbVariant - Indicates a variant (used only with arrays of Variants)
  • 13 = vbDataObject - Indicates a data-access object
  • 17 = vbByte - Indicates a byte
  • 8192 = vbArray - Indicates an array

Syntax: VarType(varname)
Example:
x="Hello World!"
response.write(VarType(x) & "<br />")
Output:
8  ScriptEngine-returns the scripting language in use.
This function can return one of the following strings:
  • VBScript - Indicates that Microsoft Visual Basic Scripting Edition is the current scripting engine
  • JScript - Indicates that Microsoft JScript is the current scripting engine
  • VBA - Indicates that Microsoft Visual Basic for Applications is the current scripting engine
Syntax:
ScriptEngine
Example:
response.write(ScriptEngine & "<br />")
Output:
VBScript




No comments:

Post a Comment