VB.Net program to demonstrate the Chr() function

Here, we are going to demonstrate the Chr() function in VB.Net.
Submitted by Nidhi, on December 04, 2020 [Last updated : March 05, 2023]

Chr() function in VB.Net

The Chr() function is used to get character against the given ASCII value.

Syntax

Chr(num)

Parameter(s)

  • num: It is an ASCII value.

Return Value

The Chr() function will return the character corresponding ASCII value.

VB.Net code to demonstrate the example of Chr() function

The source code to demonstrate the Chr() function is given below. The given program is compiled and executed successfully.

'VB.Net program to demonstrate the Chr() function.

Module Module1

    Sub Main()
        Dim num As Integer = 67
        Dim ch As Char

        ch = Chr(num)

        Console.WriteLine("Character: {0}", ch)
    End Sub

End Module

Output:

Character: C
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1 that contains a Main() method. In the Main() method, we created two variables num and ch, here variable num is initialized with 67. As we know that the 67 is the ASCII value of character "C".

ch = Chr(num)

In the above code, we used the Chr() function that will return the character corresponding ASCII value. Then we printed the character on the console screen.

VB.Net Basic Programs »






Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.