Increment a character

Posted on 2005-03-07
Medium Priority
Last Modified: 2010-04-23

How would I increment a character in a string? For instance A -> B, Y -> Z

Question by:nosoup
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 96

Accepted Solution

Lee W, MVP earned 800 total points
ID: 13480438
Probably using ASCII.

Char = Chr(Asc(Char) + 1)

Only you might want to add error checking to avoid going beyond Z

See www.asciitable.com
LVL 12

Assisted Solution

S-Twilley earned 600 total points
ID: 13480637
leew's solution should work... but just to double check, when you say a character in a string... does the string just contain one character... or is it a larger string and you want to increment a particular character within it?

If you need more help, give a little more detail on what conditions you want for incrementing... although I'll leave it up to Leew to answer since I got here late ;o)


possible cases

a->b    y->z    ...

z-> a   ?


z->A  ?

and on that note...

Z->A  or  Z-> a  ?

what about if the character you are incrementing happens to be a number, or punctuation? or a system char?  you can ignore this if you are validating the characters before hand but if you need more help, then elaborate a bit more :P

Assisted Solution

RealMrTea earned 600 total points
ID: 13480659
You can check to see if you newly created char is a letter by saying Char.IsLetter(newChar)

If it is, it is another number in your seriese...otherwise, you need to start over or move from capital letters to lower case.

a = 65
z = 90
A = 97
Z = 122


Author Comment

ID: 13480687
that will do nicely, cheers
LVL 12

Expert Comment

ID: 13480718
thanx for the points... but I didnt really do anything in that post... was trying to prompt you to give more details if you wanted Leew to elaborate.   Thanx all the same though

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question