Pages

Saturday, 30 June 2012

String Functions of VB.NET(Part II)

Split Function: Split Function in VB.NET is used to break string using a specific delimiter. For eg. Split function break string into three part 'red', 'green' and 'blue' by using delimiter ',' as shown given below:-
Public Sub str_split()

        Dim str() = Split("red,green,blue", ",")
        For i = 0 To str.Length - 1
            MsgBox(str(i))
        Next
 
End Sub



InStr Function: InStr Function in VB.NET is used to find the starting position of a substring inside a string. For eg. InStr function return 15 as the substring 'VB.NET' is in the beginning of the string as shown given below:-

Public Sub InStrg()

        MsgBox("Starting index of VB.NET is:: " & InStr("Hello This Is VB.NET Code", "VB.NET"))

End Sub



LCase Function: LCase Function in VB.NET is used to returns a string after converting to lowercase. For eg. LCase function is used to converted 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' to 'abcdefghijklmnopqrstuvwxyz' lowercase alphabets as shown given below:-

Public Sub Lower_case()

        Dim Str As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        MsgBox("String in Lowercase is::" & LCase(Str))

End Sub



LTrim Function: LTrim Function in VB.NET is used to retruns a copy of a string without leading spaces. For eg. LTrim function remove the leading spaces from String such as '                  VB.NET' become 'VB.NET' as shown given below:-


Public Sub L_trim()

        MsgBox("String after removing leading spaces is:: " & LTrim("                  VB.NET"))

End Sub

No comments:

Post a Comment