VB functions



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

Date/Time function

  • Date/Time function

  • Conversion function

  • Format function

  • Math function

  • Array function

  • ##String function

  • Other functions

FunctionDescription
CDate Valid date and time expressions are converted to Date type.
Date Returns the current system date.
DateAdd Returns the date to which the specified time interval has been added.
DateDiffReturns the number of time intervals between two dates.
DatePartReturns the specified part of the given date.
DateSerialReturns the date of the specified year, month, and day.
DateValue Returns the date.
DayReturns the number representing the day of the month (between and including 1 to 31).
FormatDateTime Returns an expression formatted as a date or time.
HourReturns a number representing the hour of the day (between and including 0 to 23).
IsDateReturns a Boolean value indicating whether the calculation expression can be converted to a date.
MinuteReturns a number representing the minute of the hour (between and including 0 to 59).
MonthReturns a number representing the month of the year (between and including 1 to 12).
MonthNameReturns the name of the specified month.
Now Returns the current system date and time.
SecondReturns a number representing the second of the minute (between and including 0 to 59).
TimeReturns the current system time.
TimerReturns the number of seconds since 12:00 AM.
TimeSerialReturns the time for a specific hour, minute, and second.
TimeValue Returns the time.
WeekdayReturns a number representing the day of the week (between and including 1 to 7).
WeekdayNameReturns the weekday name of the specified day of the week.
Year Returns a number representing the year.

Conversion function

Top
FunctionDescription
AscConvert the first letter in the string to ANSI characters code.
CBoolConvert the expression to Boolean type.
CByteConvert the expression to Byte type.
CCurConvert the expression to currency (Currency) type.
CDateConvert valid date and time expressions to date (Date) type.
CDblConvert the expression to double precision (Double) type.
ChrConvert the specified ANSI character code into characters.
CIntConvert the expression to the integer (Integer) type.
CLngConvert the expression to long integer (Long) type.
CSngConvert the expression to single precision (Single) type.
CStrConvert the expression to string type.
Hex Returns the hexadecimal value of the specified number.
OctReturns the octal value of the specified number.

Top
##Format function

Function DescriptionFormatCurrencyReturns as a currency value formatted expression. FormatDateTime Returns an expression formatted as a date or time. FormatNumber Returns an expression formatted as a number. FormatPercentReturns an expression formatted as a percentage.

Top
Math function

Function Description
AbsReturns the absolute value of the specified number.
AtnReturns the arc tangent of the specified number.
CosReturns the cosine of the specified number (angle).
ExpReturns e (the base of natural logarithms) raised to the power.
Hex Returns the hexadecimal value of the specified number.
IntReturns the integer part of the specified number.
FixReturns the integer part of the specified number.
LogReturns the natural logarithm of the specified number.
OctReturns the octal value of the specified number.
RndReturns a random number less than 1 but greater than or equal to 0.
Sgn Returns an integer that indicates the sign of the specified number.
SinReturns the sine of the specified number (angle).
SqrReturns the square root of the specified number.
TanReturns the tangent of the specified number (angle).

Array function

Top
Function Description
ArrayReturns a variable containing an array.
FilterReturns a zero-based array containing a subset of the string array based on the specified filter criteria.
IsArrayReturns a Boolean value indicating whether the specified variable is an array.
JoinReturns a string composed of several substrings in the array.
LBound Returns the smallest subscript indicating the dimension of the array.
SplitReturns a zero-based one-dimensional array containing the specified number of substrings.
UBound Returns the maximum subscript indicating the dimension of the array.

String function

Top
FunctionDescription
InStrReturns the first occurrence of a string in another string s position. The search starts from the first character of the string.
InStrRevReturns the position of the first occurrence of a string within another string. The search starts from the last character of the string.
LCaseConvert the specified string to lowercase.
LeftReturns the specified number of characters from the left side of the string.
LenReturns the number of characters in the string.
LTrimRemove spaces on the left side of the string.
RTrimRemove spaces on the right side of the string.
TrimRemove spaces on the left and right sides of the string.
MidReturns the specified number of characters from a string.
ReplaceReplaces the specified portion of a string with another string a specified number of times.
Right Returns the specified number of characters from the right side of the string.
SpaceReturns a string consisting of the specified number of spaces.
StrCompCompares two strings and returns a value representing the comparison result.
String Returns a string containing repeated characters of the specified length.
StrReverseReverse a string.
UCaseConvert the specified string to uppercase.

Top
##Other functions

Function Description
CreateObjectCreates an object of the specified type.
EvalEvaluates the expression and returns the result.
GetLocaleReturns the current locale ID.
GetObjectReturns a reference to the automation object in the file.
GetRefAllows 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, and then return the content.
IsEmptyReturns 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.
IsObjectReturns a Boolean value indicating whether the specified expression is an automation object.
LoadPictureReturns a picture object. For use on 32-bit platforms only.
MsgBoxDisplays a message box, waits for the user to click a button, and returns a value indicating which button the user clicked.
RGBReturns a number representing the RGB color value.
RoundRounds the number.
ScriptEngine Returns the scripting language in use.
ScriptEngineBuildVersionReturns the build number of the script engine in use.
ScriptEngineMajorVersionReturns the major version number of the script engine in use.
ScriptEngineMinorVersionReturns the minor version number of the script engine in use.
SetLocaleSet the locale ID and return the previous locale ID.
TypeNameReturns the subtype of the specified variable.
VarType Returns a value indicating the subtype of the variable.