get alphanumeric using number

the below code , returns integer only , but i need alphanumeric
like aB12C2 with lowercase n uppercase mixed .

Following this url ..
http://www.eggheadcafe.com/articles/20040331.asp
Dim test As String = "12345"
        Dim finalStr As String = ""
        Dim y As Integer = 0
        For i As Integer = 0 To test.Length - 1
            y = Int32.Parse(test(i)) + 1a
            finalStr += y.ToString()
        Next
        Response.Write(finalStr)

Open in new window

LVL 18
Rajar AhmedConsultantAsked:
Who is Participating?
 
Paul MacDonaldConnect With a Mentor Director, Information SystemsCommented:
Okay, I just hacked this out:

    Dim test As String = "a1B2c3"
    Dim y As String = Nothing
    Dim finalstr As String = Nothing
    For i As Integer = 0 To test.Length - 1
      y = Chr(Asc(test(i)) + 1)
      finalstr += y.ToString()
    Next
      Response.Write(finalstr & "<br />")

It takes "a1B2c3" and returns "b2C3d4"
0
 
Paul MacDonaldDirector, Information SystemsCommented:
This is what's making it numeric:
     y = Int32.Parse(test(i)) + 1a

You could replace that with something that generates valid ASCII characters, but you'd have to re-write it so the values you generated were all valid.
0
 
Paul MacDonaldDirector, Information SystemsCommented:
In other words, you could write something where y is a random ASCII character value.  The numbers 0 through 9 are CHR(48) through CHR(57), upper case letters are CHR(65) though CHR(90), and lower case letters are CHR(97) through CHR(122).

0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Rajar AhmedConsultantAuthor Commented:
i dont want to use random value .
now that
if,test  is 12345 the final value is 23456
Similarly  want to get
12345 the final value should b aB12C3
it should be constant always whenever test string is 12345.

0
 
Paul MacDonaldDirector, Information SystemsCommented:
I'm not sure I get what you're after.  If the input is always aB12C3, you want the output to always be aB12C3?  If so, why convert it at all?

Or are you saying you want 12345 to always convert to aB12C3?

Do you understand what the original code is doing?
0
 
Rajar AhmedConsultantAuthor Commented:
yes , i understand that
code is simple it jus add 1 with the test string loop
and returns final string as integer

Test string is 123456 - > while executing for Loop ->it gives  23456
Expected Result should be
123456 -> on for loop - > i want it as alphanumeric

if u see in this example,
http://www.eggheadcafe.com/articles/20040331.asp

this logic is used for checking captcha image text .
but all i want is alpha numeric code in that particular image  ?
0
 
Paul MacDonaldDirector, Information SystemsCommented:
So, you want to increment the values by one?

You can try replacing
           y = Int32.Parse(test(i)) + 1a
            finalStr += y.ToString()

with something like
           y = CHR(ASC(test(i) + 1)
            finalStr += y


But you'll run into problems with input values of 9, Z, and z which will return :, [, and (, respectively.
0
 
Rajar AhmedConsultantAuthor Commented:
input is always numeric .
i need output as alphanumeric ?
With output  Formatted like
aB12C3 (combination of lower case,upper case,numeric )

ur code dint worked
i change like below ,
y = AscW(Chr(Asc(test(i)))) + 1
but the result is same numeric
5856575554
For i As Integer = 0 To test.Length - 1
            'y = Int32.Parse(test(i)) + 1
            y = AscW(Chr(Asc(test(i)))) + 1
            finalStr += y.ToString()
 Next

Open in new window

0
 
Paul MacDonaldDirector, Information SystemsCommented:
Yeah, I didn't get a chance to test my code - I wrote it off the cuff.  The point was to convert the input string to and ASCII integer value, add 1, then convert back to an ASCII character.  I'll work on it in a bit and get back to you if you don't figure it out first.
0
 
Rajar AhmedConsultantAuthor Commented:
thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.