Friday, August 13, 2010

Visual Basic String Function : Replace

Purpose : Replace enables you to substitute a specified string value within a given string for a specified number of times.

Syntax :
Replace ( expression, find , replacewith [ , start [ , count [ , compare ] ] ] )

expression : String value containing the value to be replaced.
find : String value being searched for.
replacewith : String value to replace the value specified in the find argument.
start : Position within the expression from which to start the search for the find string value .
count : Number of times the find and replace will be performed within the string expression.
compare : Numeric value indicating the kind of comparison to use when evaluating substrings
0 : vbBinaryCompare
1 : vbTextCompare
2 : vbDatabaseCompare.

s = Replace ( "Michael Smith Jr. " , "Smith" , "Smythe" , compare : = vbBinaryCompare )

No comments:

Post a Comment