Converting a character code to char (VB.NET)

北城余情 提交于 2019-11-29 15:57:30

问题


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?


回答1:


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.



回答2:


Use the Chr or ChrW function, Chr(charNumber).




回答3:


You could use the Chr(int) function




回答4:


you can also use

Dim intValue as integer = 65  ' letter A for instance
Dim strValue As String = Char.ConvertFromUtf32(intValue)

this doesn't requirement Microsoft.VisualBasic reference



来源:https://stackoverflow.com/questions/4857866/converting-a-character-code-to-char-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!