Home >>VB.Net Built-in Functions >VB.Net program to demonstrate the Asc() function

VB.Net program to demonstrate the Asc() function

Write a VB.Net program to demonstrate the Asc() function

The function Asc() is used to obtain the corresponding ASCII value of the given character.

Syntax :

Asc(character)

Parameters :

  • Character: This is a string with a single character in it.

Return Value :

The Asc() function returns an ASCII value corresponding to the character defined.

Program :

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


Module Module1
    Sub Main()
        Dim num As Integer = 0
        num = Asc("c")
        Console.WriteLine("Ascii value: {0}", num)
    End Sub
End Module
	
Output:
Ascii value: 99

Explanation:

We created a Module1 module in the program above that contains the Main() method. We created a variable num in the Main() method, which is initialized with 0.

num = Asc("c")

We used the Asc() function in the above code that returns the ASCII value corresponding to the given character. Then, on the console screen, we printed a character.


No Sidebar ads