Chr Function in VB.NET

How to convert ascii value to character in Vb.Net?

Explanation

Chr Function - Convert Ascii Value to Character

Chr Function in Visual Basic.net 2008 is used to return the character for the specified Character Code(Ascii Value).
Syntax:

Function Chr(ByVal CharCode As Integer) As Char

In the above syntax CharCode specifies the Character Code based on which the associated character is returned.
Example:

Module Module1
Sub Main()
Console.WriteLine("Character for Character
Code 45 is::" & Chr("45"))
Console.WriteLine("Character for Character
Code 76 is::" & Chr("76"))
Console.ReadLine()
End Sub
End Module
Result:

Character for Character Code 45 is::-
Character for Character Code 76 is::L

In the above example, the character for the the ascii value '45' and '76' are returned as '-' and 'L' using chr convert function.

Visual Basic Tutorial


Ask Questions

Ask Question