VBScript Functions

This page will provide you with a quick look at the more important VBScript functions. They include functions for type checking, date manipulation, string manipulation, formatting, math, and more.

Type Checking Functions

Function Description
VarType Returns an integer code that indicates the subtype of a variable.
TypeName Returns the subtype of a variable.
IsNumeric Returns a Boolean value indicating whether an expression can be evaluated as a number.
IsArray Returns a Boolean value indicating whether a variable is an array.
IsDate Returns a Boolean value indicating whether the expression can be converted to a date.
IsEmpty Returns a Boolean value indicating whether a variable has been initialized or not.
IsNull Returns a Boolean value that indicates whether an expression contains no valid datatype.
IsObject Returns a Boolean value indicating whether an expression refers to an Automation object.

Conversion Functions

Function Description
CBool Converts an expression to a Boolean subtype.
CByte Converts an expression to a Byte subtype.
CCur Converts an expression to a Currency subtype.
CDate Converts an expression to a Date subtype.
CDbl Converts an expression to a Double subtype.
CInt Converts an expression to a Integer subtype.
CLng Converts an expression to a Long subtype.
CSng Converts an expression to a Single subtype.
CStr Converts an expression to a String subtype.

Format Functions

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 percent value with a trailing percent (%) symbol.

String Functions

Function Description
Join Returns a string created by joining strings stored in an array.
Filter Returns a zero-based array containing subset of a string array based on a filter criteria.
InStr Returns the numeric position of the first occurrence of one string within another.
InStrRev Returns the numeric position of the first occurrence of one string within another starting from the end of the string.
LCase Returns a string with all its uppercase letters converted to lowercase letters.
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 all the spaces from the left side of a string.
RTrim Removes all the spaces from the right side of a string.
Trim Removes spaces from both the left and the right sides of a string.
Mid Returns a specified number of characters from a string.
Replace Returns a string in which a specified sub-string has been replaced with another substring 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 the number of defined spaces.
Split Returns a zero-based, one-dimensional array that contains a specified number of substrings.
StrComp Compares two strings and returns a value indicating the result of the comparison.
String Returns a string consisting of character repeated number times.
StrReverse Returns a string where the character order has been reversed.
UCase Returns string with all its lowercase letters converted to uppercase letters.

Date Functions

Function Description
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 a date for a specified year, month, and day.
DateValue Returns a date.
Day Returns a number representing the day of the month (between 1 and 31, inclusive).
Hour Returns a number representing the hour of the day (between 0 and 23, inclusive).
Minute Returns a number of the minutes in current system time (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 a specified month.
Now Returns the current system date and time.
Second Returns the current seconds value of the current system time (between 0 and 59, inclusive).
Time Returns the current system time.
TimeSerial Returns the time for a specific hour, minute, and second.
TimeValue Returns the current system time.
Weekday Returns a number representing the day of the week (between 1 and 7, inclusive).
WeekdayName Returns the weekday name of a specified day of the week.
Year Returns a number representing the year.

Math Functions

Function Description
Abs Returns the absolute value of a number.
Atn Returns the arctangent of a number.
Cos Returns the cosine of an angle.
Exp Returns e, the base of natural logarithms, raised to a power.
Hex Returns a string representing the hexadecimal value of a number.
Int Returns the integer portion of a number. If number is negative, Int returns the first integer less than or equal to number.
Fix Returns the integer portion of a number. If number is negative, Fix returns the first integer greater than or equal to number.
Log Returns the natural logarithm of a number.
Oct Returns a string representing the octal value of a number.
Rnd Returns a random number less than 1 but greater or equal to 0.
Round Returns a number rounded to a specified number of decimal places.
Sgn Returns an integer indicating the sign of a number.
Sin Returns the sine of an angle.
Sqr Returns the square root of a number.
Tan Returns the tangent of an angle.

Other Functions

Function Description
Chr Returns the character specified by the ANSI character code.
Array Returns an array containing the specified values.
Asc Returns the ANSI character code of a string.
LBound Returns the lower limit for the elements in an array.
UBound Returns the upper limit for the number of elements in an array.
admin

admin

Leave a Reply

Your email address will not be published.