Pages

Friday, 29 June 2012

String Functions of VB.NET(Part I)

Asc Function: Asc Function in VB.NET is used to return the ascii code for the first character in the string. For eg. Ascii code for A,B,C are 65, 66, 67 respectively as shown given below:-

Public Sub ascii()

        MsgBox("Character Code of A :: " & Asc("A"))
        MsgBox("Character Code of B :: " & Asc("B"))
        MsgBox("Character Code of C :: " & Asc("C"))
      
End Sub 


Chr Function: Chr Function in VB.NET is used to return the character for the specified Ascii value. For eg. character code for 65 to 90 represent the Capital A to Z  as shown given below:-


Public Sub chr_code()

        For i = 65 To 90
            MsgBox("Character " & i & " is :: " & Chr(i))
        Next
 
End Sub


GetChar Function: GetChar Function in VB.NET is used to return the character of the string from the specified index. For eg. character W, T, A return index 1, 9, 12  as shown given below:-

Public Sub GetCharacter()

        Dim Str As String = "Welcome To All"
        For i = 1 To 14
            MsgBox("Character at the index value " & i & " is :: " & GetChar(Str, i))
        Next
 
End Sub

No comments:

Post a Comment