views:

364

answers:

1

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
just watch out for incrementing "z". Ascii "z" + 1 = "{".
Glen
thank you. had to use Microsoft.VisualBasic.ChrW((Asc(letter) + 1)) though.