.NODE

Appendix B Built-In VBScript Functions

Overview

VBScript provides an enormous collection of built-in functions as outlined in Table B.1. You can use these functions in your VBScripts to shorten your development time and save yourself from having to reinvent the wheel.


VBScript Functions

Table B.1: BUILT-IN VBSCRIPT FUNCTIONS

Function Name

Description

Abs

Retrieves a number's absolute value

Array

Returns an array based on the supplied argument list

Asc

Returns the ANSI code of the first letter in the supplied argument

Atn

Inverse trigonometric function that returns the arctangent of the argument

CBool

Converts an expression to a Boolean value and returns the result

CByte

Converts an expression to a variant subtype of Byte and returns the result

CCur

Converts an expression to a variant subtype of Currency and returns the result

CDate

Converts an expression to a variant subtype of Date and returns the result

CDbl

Converts an expression to a variant subtype of Double and returns the result

Chr

Returns a character based on the supplied ANSI code

CInt

Converts an expression to a variant subtype of Integer and returns the result

CLng

Converts an expression to a variant subtype of Long and returns the result

Cos

Trigonometric function that returns the cosine of the argument

CreateObject

Creates an automation object and returns a reference to it

CSng

Converts an expression to a variant subtype of Single and returns the result

Date

Returns the current date

DateAdd

Adds an additional time interval to the current date and returns the result

DateDiff

Compares two dates and returns the number of intervals between them

DatePart

Returns a portion of the specified date

DateSerial

Returns a Variant (subtype Date) based on the supplied year, month, and day

DateValue

Converts a string expression into a variant of type Date and returns the result

Day

Converts an expression representing a date into a number between 1 and 31 and returns the result

Eval

Returns the results of an evaluated expression

Exp

Returns the value of an argument raised to a power

Filter

Returns an array based on a filtered set of elements using supplied filter criteria

FormatCurrency

Returns an expression that has been formatted as a currency value

FormatDateTime

Returns an expression that has been formatted as a date or time value

FormatNumber

Returns an expression that has been formatted as a numeric value

FormatPercent

Returns an expression that has been formatted as a percentage (including the accompanying %)

GetLocale

Returns the locale ID

GetObject

Returns a reference for an Automation object

GetRef

Returns a reference for a procedure

Hex

Returns a hexadecimal string that represents a number

Hour

Returns a whole number representing an hour in a day (0 – 23)

InputBox

Returns user input from a dialog box

InStr

Returns the starting location of the first occurrence of a substring within a string

InStrRev

Returns the ending location of the first occurrence of a substring within a string

Int

Returns the integer portion from the supplied number.

IsArray

Returns a value of True or False depending on whether a variable is an array

IsDate

Returns a value of True or False depending on whether an expression is properly formatted for a data conversion

IsEmpty

Returns a value of True or False depending on whether a variable is initialized

IsNull

Returns a value of True or False depending on whether an expression is set to Null

IsNumeric

Returns a value of True or False depending on whether an expression evaluates to a number

IsObject

Returns a value of True or False depending on whether an expression has a valid reference for an Automation object

Join

Returns a string that has been created by concatenating the contents of an array

Lbound

Returns the smallest possible subscript for the specified array dimension

Lcase

Returns a lowercase string

Left

Returns characters from the left side of a string

Len

Returns a number or string's character length

LoadPicture

Returns a picture object

Log

Returns the natural log of the specified argument

LTrim

Trims any leading blank spaces from a string and returns the result

Mid

Returns a number of characters from a string based on the supplied start and length arguments

Minute

Returns a number representing a minute within an hour in the range of 0–59

Month

Returns a number representing a month within a year in the range of 1–12

MonthName

Returns a string containing the name of the specified month

MsgBox

Returns a value specifying the button that the user clicked in a dialog box

Now

Returns the current date and time.

Oct

Returns a string containing an octal number representation

Replace

Returns a string after replacing occurrences of one substring with another substring

RGB

Returns a number that represents an RGB color

Right

Returns characters from the right side of a string

Rnd

Returns a randomly generated number

Round

Returns a number after rounding it by a specified number of decimal positions

RTrim

Trims any trailing blank spaces from a string and returns the result

ScriptEngine

Returns a string identifying the current scripting language

ScriptEngineBuildVersion

Returns the scripting engine's build number

ScriptEngineMajorVersion

Returns the scripting engine's major version number

ScriptEngineMinorVersion

Returns the scripting engine's minor version number

Second

Returns a number representing a second within a minute in the range of 0–59

SetLocale

Establishes the global locale and retrieves the previous locale

Sgn

Returns the sign of the specified argument

Sin

Trigonometric function that returns the sine of the argument

Space

Returns a string consisting of a number of blank spaces

Split

Organizes a string into an array

Sqr

Returns a number's square root

StrComp

Returns a value that specifies the results of a string comparison

String

Returns a character string made up of a repeated sequence of characters

Tan

Trigonometric function that returns the tangent of the argument

Time

Returns a Variant of subtype Date that has been set equal to the system's current time

Timer

Returns a value representing the number of seconds that have passed since midnight

TimeSerial

Returns a Variant of subtype Date that has been set equal to containing the specified hour, minute, and second

TimeValue

Returns a Variant of subtype Date that has been set using the specified time

Trims

Returns a string after removing any leading or trailing spaces

TypeName

Returns a string that specified the Variant subtype information regarding the specified variable

Ubound

Returns the largest subscript for the specified array dimension

Ucase

Returns an uppercase string

VarType

Returns a string that specified the Variant subtype information regarding the specified variable

Weekday

Returns a whole number in the form of 1–7, which represents a given day in a week

WeekdayName

Returns a string identifying a particular day in the week

Year

Returns a number specifying the year






Microsoft WSH and VBScript Programming for the Absolute Beginner
Microsoft WSH and VBScript Programming for the Absolute Beginner
ISBN: 159200072X
EAN: 2147483647
Year: 2005
Pages: 137
Similar book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net