VBScript Functions

This page lists all built-in VBScript functions:

Date/Time Functions

Function Description
CDate Converts a valid date or time expression to a date type.
Date Returns the current system date.
DateAdd Returns the date after adding the specified time interval.
DateDiff Returns the number of time intervals between two dates.
DatePart Returns the specified part of the given date.
DateSerial Returns the specified year, month, and day of the date.
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 the calculation expression can be converted to a date.
Minute 返回一个数字,代表小时的分钟 (介于并包括0至59)
Minute Returns a number representing the minutes 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 seconds 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.
TimeValue Returns the time.
Weekday Returns a number representing the day of the week (between and including 1 and 7).
WeekdayName Returns the name of the day of the week for a specified day in the week.
Year Returns a number representing the year.

Top

Conversion Functions

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

Top

Format Function

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.

Top

Math Functions

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 (in degrees).
Exp Returns e (the base of the natural logarithm) to the power of a specified number.
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 cosine 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.
Rnd Returns a random number less than 1 but greater than or equal to 0.
Sqr Returns the square root of a specified number.
Tan Returns the tangent of a specified number (angle).

Top

Array Function

Function Description
Array Returns a variable containing an array
Filter Returns an array starting from index zero, which contains a subset of string arrays based on a specific filtering condition.
IsArray Returns a boolean value indicating whether the specified variable is an array.
Join Returns a string composed of several substrings from an array.
LBound Returns the minimum index of the specified array dimension.
Split Returns a one-dimensional array starting from index 0, containing a specified number of substrings.
UBound Returns the maximum index of the specified array dimension.

Top

String Function

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

Top

Other Functions

Function Description
CreateObject Creates an object of the specified type.
Eval Calculates an expression and returns the result.
GetLocale Returns the ID value of the current locale.
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 webpage.
InputBox The dialog box can be displayed, where users can input text and/or click buttons, and then return the results.
IsEmpty Return a boolean value indicating whether the specified variable has been initialized.
IsNull Return a boolean value indicating whether the specified variable contains invalid data (Null).
IsNumeric Return a boolean value indicating whether the specified expression can be calculated as a number.
IsObject Return a boolean value indicating whether the specified expression is an automation object.
LoadPicture Return a picture object. Only for 32-bit platforms.
MsgBox Display a message box, wait for the user to click a button, and return the value indicating which button the user clicked.
RGB Return a number representing the RGB color value.
Round Round the logarithm.
ScriptEngine Return the script language in use.
ScriptEngineBuildVersion Return the version number of the script engine in use.
ScriptEngineMajorVersion Return the major version number of the script engine in use.
ScriptEngineMinorVersion Return the minor version number of the script engine in use.
SetLocale Set the region ID and return the previous region ID.
TypeName Return the sub-type of the specified variable.
VarType Return the value indicating the sub-type of the indicator variable.

Top