C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
VB.NET program that uses Val, Asc, AscW
Module Module1
Sub Main()
' Use Val and AscW on char.
Dim c As Char = "a"c
Dim i As Integer = Val(c)
Dim a As Integer = Asc(c)
Console.WriteLine(c)
Console.WriteLine(i)
Console.WriteLine(a)
' Another character.
Dim c2 As Char = "2"c
Dim i2 As Integer = Val(c2)
Dim a2 As Integer = AscW(c2) ' AscW is similar to Asc
Console.WriteLine(c2)
Console.WriteLine(i2)
Console.WriteLine(a2)
End Sub
End Module
Output
a
0
97
2
2
50
Note: The Val, Asc and AscW functions are only available in the VB.NET language, not the C# language.
Tip: If you want to get the number from the Char and turn it into an Integer, the Val function is best.