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?
+3
A:
You could get the ascii code, increment, and convert back to Char:
Chr(Asc(letter) + 1)
The Unicode version of this is:
ChrW(AscW(letter) + 1)
EDIT:
As Glen pointed out, you need to be careful if you are trying to increment "z"c
Patrick McDonald
2009-05-19 13:03:58
just watch out for incrementing "z". Ascii "z" + 1 = "{".
Glen
2009-05-19 13:07:07
thank you. had to use Microsoft.VisualBasic.ChrW((Asc(letter) + 1)) though.
2009-05-19 13:10:40