VBScript Functions


This page lists all built-in VBScript functions, mainly divided into the following categories:

Date/Time Functions

Function Description
CDate Converts a valid date and time expression to a Date type.
Date Returns the current system date.
DateAdd Returns a date to which the specified time interval has been added.
DateDiff Returns the number of time intervals between two dates.
DatePart Returns the specified part of a given date.
DateSerial Returns a date for the specified year, month, and day.
DateValue Returns a date.
Day Returns a number representing the day of the month (between 1 and 31, inclusive).
FormatDateTime Returns an expression formatted as a date or time.
Hour Returns a number representing the hour of the day (between 0 and 23, inclusive).
IsDate Returns a Boolean value indicating whether the evaluated expression can be converted to a date.
Minute Returns a number representing the minutes of the hour (between 0 and 59, inclusive).
Month Returns a number representing the month of the year (between 1 and 12, inclusive).
MonthName Returns the name of the specified month.
Now Returns the current system date and time.
Second Returns a number representing the seconds of the minute (between 0 and 59, inclusive).
Time Returns the current system time.
Timer Returns the number of seconds since 12:00 AM.
TimeSerial Returns a time for a specific hour, minute, and second.
TimeValue Returns a time.
Weekday Returns a number representing the day of the week (between 1 and 7, inclusive).
WeekdayName Returns the weekday name of the specified day of the week.
Year Returns a number representing the year.

Conversion Functions

Top
Function Description
Asc Converts the first letter in a string to an ANSI character code.
CBool Converts an expression to a Boolean type.
CByte Converts an expression to a Byte type.
CCur Converts an expression to a Currency type.
CDate Converts a valid date and time expression to a Date type.
CDbl Converts an expression to a Double type.
Chr Converts the specified ANSI character code to a character.
CInt Converts an expression to an Integer type.
CLng Converts an expression to a Long type.
CSng Converts an expression to a Single type.
CStr Converts an expression to a String type.
Hex Returns the hexadecimal value of the specified number.
Oct Returns the octal value of the specified number.

Format Functions

Top
Function Description
FormatCurrency Returns an expression formatted as a currency value.
FormatDateTime Returns an expression formatted as a date or time.
FormatNumber Returns an expression formatted as a number.
FormatPercent Returns an expression formatted as a percentage.

Math Functions

Top
Function Description
Abs Returns the absolute value of the specified number.
Atn Returns the arctangent of the specified number.
Cos Returns the cosine of the specified number (angle).
Exp Returnsethe power of e (the base of natural logarithms).
Hex Returns the hexadecimal value of the specified number.
Int Returns the integer part of the specified number.
Fix Returns the integer part of the specified number.
Log Returns the natural logarithm of the specified number.
Oct Returns the octal value of the specified number.
Rnd Returns a random number less than 1 but greater than or equal to 0.
Sgn Returns an integer indicating the sign of the specified number.
Sin Returns the sine of the specified number (angle).
Sqr Returns the square root of the specified number.
Tan Returns the tangent of the specified number (angle).

Array Functions

Top
Function Description
Array Returns a variable containing an array.
Filter Returns a zero-based array containing a subset of a string array based on specific filter criteria.
IsArray Returns a Boolean value indicating whether the specified variable is an array.
Join Returns a string consisting of several substrings in an array.
LBound Returns the smallest subscript indicating the dimension of an array.
Split Returns a zero-based one-dimensional array containing the specified number of substrings.
UBound Returns the largest subscript indicating the dimension of an array.

String Functions

Top
Function Description
InStr Returns the position of the first occurrence of a string within another string. The search begins at the first character of the string.
InStrRev Returns the position of the first occurrence of a string within another string. The search begins at the last character of the string.
LCase Converts the specified string to lowercase.
Left Returns the specified number of characters from the left side of a string.
Len Returns the number of characters in a string.
LTrim Removes spaces from the left side of a string.
RTrim Removes spaces from the right side of a string.
Trim Removes spaces from both the left and right sides of a string.
Mid Returns the specified number of characters from a string.
Replace Replaces the specified part of a string with another string a specified number of times.
Right Returns the specified number of characters from the right side of a string.
Space Returns a string consisting of the specified number of spaces.
StrComp Compares two strings and returns a value representing the result of the comparison.
String Returns a string containing repeated characters of the specified length.
StrReverse Reverses a string.
UCase Converts the specified string to uppercase.

Other Functions

Top
Function Description
CreateObject Creates an object of the specified type.
Eval Evaluates an expression and returns the result.
GetLocale Returns the current locale ID.
GetObject Returns a reference to an automation object in a file.
GetRef Allows you to connect a VBScript subroutine to a DHTML event on a page.
InputBox Displays a dialog box in which the user can enter text and/or click buttons, and then returns the content.
IsEmpty Returns a Boolean value indicating whether the specified variable has been initialized.
IsNull Returns a Boolean value indicating whether the specified expression contains invalid data (Null).
IsNumeric Returns a Boolean value indicating whether the specified expression can be evaluated as a number.
IsObject Returns a Boolean value indicating whether the specified expression is an automation object.
LoadPicture Returns a picture object. Only used on 32-bit platforms.
MsgBox Displays a message box, waits for the user to click a button, and returns a value indicating which button the user clicked.
RGB Returns a number representing an RGB color value.
Round Rounds a number.
ScriptEngine Returns the scripting language in use.
ScriptEngineBuildVersion Returns the build version number of the scripting engine in use.
ScriptEngineMajorVersion Returns the major version number of the scripting engine in use.
ScriptEngineMinorVersion Returns the minor version number of the scripting engine in use.
SetLocale Sets the locale ID and returns the previous locale ID.
TypeName Returns the subtype of the specified variable.
VarType Returns a value indicating the subtype of a variable.

Other Extensions