Native functions in VBScript: Strings

December 2016



Functions to manipulate strings



Function Description
Filter(InputStrings, Value
[, Include</br>[, Compare]])
Selects strings from an array of strings (InputStrings), based on the criteria passed as an argument. Value is the string to be searched.

Include is an optional boolean value indicating whether the search should return strings containing a particular substring (True or False).

compare is an optional argument corresponding to a numeric value indicating the kind of comparison:
  • vbBinaryCompare (0) indicates a binary comparison.
  • vbTextCompare (1) corresponds to a textual comparison.
FormatCurrency(Expression[,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]]) Returns a formatted monetary value based on the monetary symbol defined in the system control panel. NumDigitsAfterDecimal is an optional argument

specifying the number of digits to be displayed after the decimal point. IncludeLeadingDigit is an optional argument specifying whether the 0(zeros)

located at the end should be displayed or not. IncludeLeadingDigit can have one of the following status:
  • TristateTrue (-1)indicates that the zeros at the end should be displayed;
  • TristateFalse (0) indicates that the trailing zeros should be masked;
  • TristateUseDefaults (-2) indicates that the default locale should be applied;


UseParensForNegativeNumbers is an optional argument specifying whether or not negative numbers must be written in brackets..

UseParensForNegativeNumbers may have the same status as IncludeLeadingDigit.
GroupDigits is also an optional constant can take the same three states. It defines whether groups of numbers (thousands) must be separated for

readability..
FormatDateTime(Date[, NamedFormat])Returns an expression formatted as a date or time. The NamedFormat is an optional argument that can take the following values:
  • vbGeneralDate (0) displays a date and/or time.
  • vbLongDate (1) displays a date using the long date format specified in the system locale.
  • vbShortDate (2) displays a date using the short date format specified in the system locale.
  • vbLongTime (3) displays a time using the long time format specified in the system locale.
  • vbShortTime (4) displaysa time using the short time format specified in the system locale.
FormatNumber(Expression[,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]]) Returns a formatted number. NumDigitsAfterDecimal is an optional argument specifying the number of digits to be displayed after the decimal point.

IncludeLeadingDigit is an optional argument specifying whether the 0 located at the end should be displayed or not. IncludeLeadingDigit can

have 3 states :
  • TristateTrue (-1) indicates that the trailing zeros should be displayed;
  • TristateFalse (0) indicates that the trailing zeros should be hidden;
  • TristateUseDefaults (-2) indicates that the default locale should be applied.


UseParensForNegativeNumbers is an optional argument specifying whether negative numbers must be written in brackets.

UseParensForNegativeNumbers can have the same 3 states as IncludeLeadingDigit.
GroupDigits is also an optional constant can take the same three states. It defines whether groups of numbers (thousands) must be separated for

readability...
FormatPercent(Expression[,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])Returns an expression formatted as a percentage (ending with %). NumDigitsAfterDecimal is an optional argument specifying the number of digits to

display after the decimal point. IncludeLeadingDigit is an optional argument specifying whether the 0 located at the end should be displayed or not.

IncludeLeadingDigit can take one of the following three states::
  • TristateTrue (-1) indicates that the trailing zeros should be displayed;
  • TristateFalse (0) indicates that the trailing zeros should be masked;
  • TristateUseDefaults (-2) indicates that the default locale should be applied..


UseParensForNegativeNumbers is an optional argument specifying whether negative numbers must be written in brackets.

UseParensForNegativeNumbers can have the same 3 states as IncludeLeadingDigit.
Enfin GroupDigits is also an optional constant can take the same three states. It defines whether groups of numbers (thousands) must be separated for

readability.
InStr([start, ]string1, string2[, compare]) Returns the position of the first occurrence of a string of characters (string2) in another one (string1). start is an optional argument defining the

character position where the search begins.
InStrRev([start, ]string1, string2[, compare]) Returns the position of the first occurrence of a string of characters (string2) in another one (string1), starting from the end.
start is an optional argument defining the character position where the search begins.

compare is an optional argument corresponding to a numeric value, indicating the kind of comparison:

  • vbBinaryCompare (0) indicates a binary comparison..
  • vbTextCompare (1) corresponds to a textual comparison.
Join(list[, delimiter])Returns a string assembled from separate elements in the list array.
delimiter delimiter is an optional character used to delimit the substrings in the returned result. Default substrings are separated by spaces.
LCase(string)Converts the string to lowercase string.
Left(string, length) Returns a specified number of characters (length) from the left of the string.
Len(string > varname)Returns the number of characters in a string or the number of bytes required to store a variable
LTrim(string)Returns a copy of the string without spaces from the beginning.
Mid(string, start[, length])Returns a specified number (length) of characters from (string).
start ddetermines the character position where the output string must begin.
Replace(expression, find, replacewith[, start[, count[, compare]]])Search and replace a substring in a string. expression correspond to the string to be searched. find correspond to the substring to be

searched in the expression. replacewith correspond to the substring that will replace the occurences of the find substring.


start, count and compare are optional arguments that will define, where to start the search (default 1), the

number of substitutions to be done (by default -1) and the type of comparaison to be made.

compare is an optional argument corresponding to a numeric value, indicating the kind of comparison::

  • vbBinaryCompare (0) indicates a binary comparaison.
  • vbTextCompare (1) corresponds to a textual comparison..
Right(string, length) Returns a number of characters (length) from the right of the string.
Rtrim(string)Returns a copy of the string without the spaces at the end.
Space(number)Returns a string consisting of the number of spaces passed as a parameter.
Split(expression[, delimiter[, count[, compare]]])Returns a one-dimensional array containing a specified number of substrings. delimiter is an optional character that delimits substrings (by default a

space is used). count is an optional argument that defines the maximum number of substrings to be returned. By default count is equal to

-1,indicating that there is no limit.compare is an optional argument corresponding to a numeric value, indicating the kind of comparison:
  • vbBinaryCompare (0) indicates a binary comparison..
  • vbTextCompare (1) corresponds to a textual comparison.
StrComp(string1, string2[, compare])Returns the result of the comparison of strings string1 and string2. If string1 is less than string2, StrComp returns -1. If string1 is equal to string2, StrComp returns 0. If string1 is greater than string2, StrComp returns 1. Finally, if string1 or string2 is Null, then StrComp returns Null.

compare is an optional argument corresponding to a numeric value, indicating the kind of comparison:

  • vbBinaryCompare (0) indicates a binary comparison..
  • vbTextCompare (1) corresponds to a textual comparison.
String(number, character)Returns a string of characters of length number repeating a specific character.
StrReverse(string1)Reverses the order of characters in string1.
Trim(string)Returns a copy of the string without the spaces at the beginning and the end.
UCase(string)Converts the string to uppercase.




Original document published CommentcaMarche.net.

Related :

This document entitled « Native functions in VBScript: Strings » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.