Sunday, August 28, 2011

String Manipulation


1. StrComp Method
 
Returns -1, 0, or 1, based on the result of a string comparison. 

Syntax:

Public Shared Function StrComp ( _
    String1 As String, _
    String2 As String, _
    Compare As CompareMethod _
) As Integer


Parameters:
String1
    Type: System.String
    Required. Any valid String expression.

String2
    Type: System.String
    Required. Any valid String expression.

Compare
    Type: Microsoft.VisualBasic.CompareMethod
    Optional. Specifies the type of string comparison. If Compare is omitted, the Option Compare

setting determines the type of comparison.


Return Value

Type: System.Int32
The StrComp function has the following return values.

If   
StrComp returns
String1 sorts ahead of String2 (-1)
String1 is equal to String2 (0)
String1 sorts after String2 (1)
   
Exception:

ArgumentException is the exception thrown by this function.(Condition: Compare value is not valid.)
______________________________________________________________________

2. StrConv Method

Returns a string converted as specified

Syntax:
Public Shared Function StrConv ( _
    str As String, _
    Conversion As VbStrConv, _
    LocaleID As Integer _
) As String


Parameters:

str
    Type: System.String
    Required. String expression to be converted.

Conversion
    Type: Microsoft.VisualBasic.VbStrConv
    Required. VbStrConv member. The enumeration value specifying the type of conversion to

perform.

LocaleID
    Type: System.Int32
    Optional. The LocaleID value, if different from the system LocaleID value. (The system

LocaleID value is the default.)

Return Value:
Type: System.String
Returns a string converted as specified.
Exceptions
Exception     Condition

Exception:
ArgumentException is the exception thrown by this function.(Condition: Unsupported LocaleID, Conversion < 0 or > 2048, or unsupported conversion for specified locale.)
_____________________________________________________________________


3. InStrRev Method
 
Returns the position of the first occurrence of one string within another, starting from the right side of the string.


Syntax:
Public Shared Function InStrRev ( _
    StringCheck As String, _
    StringMatch As String, _
    Start As Integer, _
    Compare As CompareMethod _
) As Integer


Parameters:
StringCheck
    Type: System.String
    Required. String expression being searched.

StringMatch
    Type: System.String
    Required. String expression being searched for.

Start
    Type: System.Int32
    Optional. Numeric expression setting the one-based starting position for each search, starting from the left side of the string. If Start is omitted then –1 is used, meaning the search begins at the last character position. Search then proceeds from right to left.

Compare
    Type: Microsoft.VisualBasic.CompareMethod
    Optional. Numeric value indicating the kind of comparison to use when evaluating substrings.

If omitted, a binary comparison is performed. See Settings for values.

Return Value
Type: System.Int32
If   
InStrRev returns
StringCheck is zero-length (0)
StringMatch is zero-length (Start)
StringMatch is not found (0)
StringMatch is found within StringCheck (Position at which the first match is found, starting with the right side of the string.)
Start is greater than length of StringMatch (0)

Exception:
ArgumentException is the exception thrown by this function. (Condition: Start = 0 or Start < -1.)

_______________________________________________________________________


4. StrReverse Method
Returns a string in which the character order of a specified string is reversed.
Syntax:
Public Shared Function StrReverse ( _
    Expression As String _
) As String


Parameters:
Expression
    Type: System.String
    Required. String expression whose characters are to be reversed. If Expression is a zero-

length string (""), a zero-length string is returned.

Return Value:
Type: System.String
Returns a string in which the character order of a specified string is reversed.


Exception:
ArgumentException is the exception thrown by this function.


_________________________________________________________________


5. Space Method

Returns a string consisting of the specified number of spaces.


Syntax:
Public Shared Function Space ( _
    Number As Integer _
) As String


Parameters:
Number
    Type: System.Int32
    Required. Integer expression. The number of spaces you want in the string.

Return Value:

Type: System.String
Returns a string consisting of the specified number of spaces.

Exception:
ArgumentException is the exception thrown by this function. (Condition: Number < 0.)

_____________________________________________________________________



6. StrDup Method (int32,Char)

Returns a string or object consisting of the specified character repeated the specified number of times.


syntax:


Public Shared Function StrDup ( _
    Number As Integer, _
    Character As Char _
) As String


Overload List of StrDup Method (int32,Char)
* StrDup(Int32, Char)     Returns a string or object consisting of the specified character repeated the specified number of times.

Parameters:

Number
    Type: System.Int32
    Required. Integer expression. The length to the string to be returned.

Character
    Type: System.Char
    Required. Any valid Char, String, or Object expression. Only the first character of the

expression will be used. If Character is of type Object, it must contain either a Char or a

String value.

Return Value:
Type: System.String
Returns a string or object consisting of the specified character repeated the specified number of times.


Exceptions:
*ArgumentException (Condition: Number is less than 0 or Character type is not valid.)
*ArgumentNullException (Condition: Character is Nothing.)





No comments:

Post a Comment