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

x
Solved

# Increment a character

Posted on 2005-03-07
Medium Priority
469 Views
Hi,

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

Thanks
0
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
0

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   ?

or

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
0

LVL 7

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

Later,
Eric
0

Author Comment

ID: 13480687
that will do nicely, cheers
0

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
0

## Featured Post

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
Course of the Month12 days, 3 hours left to enroll