VBScript String Functions(1)
1.LTrim
2.RTrim
3.Trim
4.Replace
5.StrReverse
6.Space
LTrim Function:Removes spaces on the left side of a string.
Syntax:LTrim(string)
Ex1:a=LTrim(" LAKSHMI ")
Msgbox a
Output=LAKSHMI .
RTrim Function:Removes spaces on the right side of a string.
Syntax:RTrim(string)
Ex1:a=RTrim(" LAKSHMI ")
Msgbox a
Output= LAKSHMI.
Trim Function:Removes spaces on both the left and the right side of a string.
Syntax:Trim(string)
Ex1:a=Trim(" LAKSHMI ")
Msgbox a
Output=LAKSHMI.
Replace Function:Replaces a specified part of a string with another string a specified number of times.
Syntax:Replace(expression, find, replacewith[, start[, count[, compare]]])
where start,count,compare are optional.
expression:String expression containing substring to replace.
find:Substring being searched for.
replacewith:Replacement substring.
start(Optional):Position within expression where substring search is to begin. If omitted,1 is assumed.
count(Optional):Number of substring substitutions to perform. If omitted, the default value is -1, which means make all possible substitutions.
compare(Optional):Numeric value indicating the kind of comparison to use when evaluating substrings.If omitted,the default value is 0, which means perform a binary comparison.
Ex1:a= Replace("abacadaeaf","a","x")
Msgbox a
Output=xbxcxdxexf.
Ex2:a=Replace("abacadaeaf","a","x",1,3)
Msgbox a
Output=xbxcxdaeaf.
As we are giving values for start and count parameters(optional)in above example only first 3 a's are replaced by x.
StrReverse Function:Reverses a string.
Syntax:StrReverse(string)
Ex1:a=StrReverse("Lakshmi")
Msgbox a
Output=imhskaL.
Space Function:Creates a string with the specified number of spaces.
Syntax:Space(number)
Ex1:a="Welcome"&space(5)&"All"
Msgbox a
Output=Welcome All.
Showing posts with label rtrim string function. Show all posts
Showing posts with label rtrim string function. Show all posts
VBScript String Functions(2)
Subscribe to:
Posts (Atom)