VBScript Functions
This page lists all built-in VBScript functions, primarily categorized as follows:
| Date/Time Functions<br> Conversion Functions<br> Format Functions | Math Functions<br> Array Functions | String Functions<br> Other Functions |
Date/Time Functions
Function | Description |
---|---|
CDate | Converts a valid date and time expression to the Date type. |
Date | Returns the current system date. |
DateAdd | Returns a date to which a specified time interval has been added. |
DateDiff | Returns the number of intervals between two dates. |
DatePart | Returns the specified part of a given date. |
DateSerial | Returns the date for a specified year, month, and day. |
DateValue | Returns a date. |
Day | Returns a number representing the day of the month (between and including 1 and 31). |
FormatDateTime | Returns an expression formatted as a date or time. |
Hour | Returns a number representing the hour of the day (between and including 0 and 23). |
IsDate | Returns a Boolean value indicating whether an expression can be converted to a date. |
Minute | Returns a number representing the minute of the hour (between and including 0 and 59). |
Month | Returns a number representing the month of the year (between and including 1 and 12). |
MonthName | Returns the name of the specified month. |
Now | Returns the current system date and time. |
Second | Returns a number representing the second of the minute (between and including 0 and 59). |
Time | Returns the current system time. |
Timer | Returns the number of seconds since 12:00 AM. |
TimeSerial | Returns the time for a specific hour, minute, and second. |
TimeValue | Returns a time. |
Weekday | Returns a number representing the day of the week (between and including 1 and 7). |
WeekdayName | Returns the 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 its ANSI character code. |
CBool | Converts an expression to the Boolean type. |
CByte | Converts an expression to the Byte type. |
CCur | Converts an expression to the Currency type. |
CDate | Converts a valid date and time expression to the Date type. |
CDbl | Converts an expression to the Double type. |
Chr | Converts the specified ANSI character code to a character. |
CInt | Converts an expression to the Integer type. |
CLng | Converts an expression to the Long type. |
CSng | Converts an expression to a Single precision type. |
CStr | Converts an expression to a String type. |
Hex | Returns the hexadecimal value of a specified number. |
Oct | Returns the octal value of a specified number. |
| Format Function | 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 a specified number. |
Atn | Returns the arctangent of a specified number. |
Cos | Returns the cosine of a specified number (angle). |
Exp | Returns e (the base of natural logarithms) raised to a power. |
Hex | Returns the hexadecimal value of a specified number. |
Int | Returns the integer part of a specified number. |
Fix | Returns the integer part of a specified number. |
Log | Returns the natural logarithm of a specified number. |
Oct | Returns the octal value of a 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 a specified number. |
Sin | Returns the sine of a specified number (angle). |
Sqr | Returns the square root of a specified number. |
Tan | Returns the tangent of a 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 a specified filter criteria. |
IsArray | Returns a Boolean value indicating whether a specified variable is an array. |
Join | Returns a string consisting of a number of substrings in an array. |
LBound | Returns the smallest subscript for the indicated dimension of an array. |
Split | Returns a one-dimensional array containing a specified number of substrings. |
UBound | Returns the largest subscript for the indicated dimension of an array. |
| String Functions | Top |
Function | Description |
---|---|
InStr | Returns the position of the first occurrence of one string within another. The search begins at the first character of the string. |
InStrRev | Returns the position of the first occurrence of one string within another. The search begins at the last character of the string. |
LCase | Converts the specified string to lowercase. |
Left | Returns a specified number of characters from the left side of a string. |
Len | Returns the number of characters in a string. |
LTrim | Removes spaces on the left side of a string. |
RTrim | Removes spaces on the right side of a string. |
Trim | Removes spaces on both the left and right sides of a string. |
Mid | Returns a specified number of characters from a string. |
Replace | Replaces a specified part of a string with another string a specified number of times. |
Right | Returns a specified number of characters from the right side of a string. |
Space | Returns a string consisting of a specified number of spaces. |
StrComp | Compares two strings and returns a value that represents the result of the comparison. |
String | Returns a string consisting of a specified length of repeated characters. |
StrReverse | Reverses a string. |
UCase | Converts a specified string to uppercase. |
| Other Functions | Top |
Function | Description |
---|---|
CreateObject | Creates an object of a specified type. |
Eval | Evaluates an expression and returns the result. |
GetLocale | Returns the current locale ID. |
GetObject | Returns a reference to an automation object from a file. |
GetRef | Allows you to connect a VBScript subroutine to a DHTML event on the page. |
InputBox | Displays a dialog box where the user can enter text and/or click a button, then returns the content. |
IsEmpty | Returns a Boolean value indicating whether a specified variable has been initialized. |
IsNull | Returns a Boolean value indicating whether a specified expression contains invalid data (Null). |
IsNumeric | Returns a Boolean value indicating whether a specified expression can be evaluated as a number. |
IsObject | Returns a Boolean value indicating whether a specified expression is an automation object. |
LoadPicture | Returns a picture object. Only for 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 to the nearest integer. |
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 a specified variable. |
VarType | Returns a value indicating the subtype of a variable. |