Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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
LVL 97

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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 …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

564 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