Asc Function in VB.NET
How to Convert String to Ascii code in VB.NET?
Explanation
Asc() Function in VB.NET - Convert String to Ascii
Asc Function in Visual Basic.net 2008 is used to return the character ascii code for the first character in the string.
Syntax:
Function Asc(ByVal String As Char) As Integer
In the above syntax,
String specifies the string whose first character is used to return the character
code.
Example:
Module Module1
Sub Main()
Console.WriteLine("Character Code of B
in Box is::" & Asc("Box"))
Console.WriteLine("Character Code of A
in A is::" & Asc("A"))
Console.ReadLine()
End Sub
End Module
Result:
Character Code of B in Box is:: 66
Character Code of A in A is:: 65
In the above example, the character ascii code for 'B' and 'A' are returned as '66' and '65' respectivley.
Convert a string to its ASCII representation may be useful when you're producing the code for HTML forms with hidden/visible field.