Hi i am trying to increment a char in vb.net, eg: Dim letter As Char = "a"c. and i want to make it b, and so on. how can i do this?
嗨我想在vb.net中增加一个字符,例如:Dim letter As Char =“a”c。我想把它变成b,依此类推。我怎样才能做到这一点?
1 个解决方案
#1
You could get the ascii code, increment, and convert back to Char:
您可以获取ascii代码,递增并转换回Char:
Chr(Asc(letter) + 1)
The Unicode version of this is:
这个的Unicode版本是:
ChrW(AscW(letter) + 1)
EDIT:
As Glen pointed out, you need to be careful if you are trying to increment "z"c
正如格伦指出的那样,如果你想增加“z”c,你需要小心
#1
You could get the ascii code, increment, and convert back to Char:
您可以获取ascii代码,递增并转换回Char:
Chr(Asc(letter) + 1)
The Unicode version of this is:
这个的Unicode版本是:
ChrW(AscW(letter) + 1)
EDIT:
As Glen pointed out, you need to be careful if you are trying to increment "z"c
正如格伦指出的那样,如果你想增加“z”c,你需要小心