VBScript Strings

Advertisements


Strings are a sequence of characters, which can consist of alphabets or numbers or special characters or all of them. A variable is said to be a string if it is enclosed within double quotes " ".

Syntax :

variablename = "string"

Examples :

str1 = "string"   ' Only Alphabets
str2 = "132.45"   ' Only Numbers
str3 = "!@#$;*"  ' Only Special Characters
Str4 = "Asc23@#"  ' Has all the above

String Functions :

There are predefined VBScript String functions, which help the developers to work with the strings very effectively. Below are String methods that are supported in VBScript. Please click on each one of the methods to know in detail.

Function NameDescription
InStrReturns the first occurence of the specified substring. Search happens from left to right.
InstrRevReturns the first occurence of the specified substring. Search happens from Right to Left.
LcaseReturns the lower case of the specified string.
UcaseReturns the Upper case of the specified string.
LeftReturns a specific number of characters from the left side of the string.
RightReturns a specific number of characters from the Right side of the string.
MidReturns a specific number of characters from a string based on the specified parameters.
LtrimReturns a string after removing the spaces on the left side of the specified string.
RtrimReturns a string after removing the spaces on the right side of the specified string.
TrimReturns a string value after removing both leading and trailing blank spaces.
LenReturns the lenght of the given string.
ReplaceReturns a string after replacing a string with another string.
SpaceFills a string with the specified number of spaces.
StrCompReturns an integer value after comparing the two specified strings.
StringReturns a String with a specified character the specified number of times.
StrReverseReturns a String after reversing the sequece of the characters of the given string.


Advertisements
Advertisements