Converting a character code to char (VB.NET)

Freesnöw picture Freesnöw · Feb 1, 2011 · Viewed 192.2k times · Source

I'm able to convert a character to its corresponding character/ASCII code using "Asc(CHAR)". What can I use to convert this returned integer back to its original character form?

Answer

Jason Yost picture Jason Yost · Feb 1, 2011

The Chr function in VB.NET converts the integer back to the character:

Dim i As Integer = Asc("x") ' Convert to ASCII integer.
Dim x As Char = Chr(i)      ' Convert ASCII integer to char.