Reversing this code (getting UN-ASCII of the string)

This code reverses the string and gives me the ASCII of the string. Now I have the ASCII code , how can I get reverse the code and get the actuall string back again?
Dim test As String = "123456789012345"
 
        Dim lLen As Integer, lCtr As Integer
        Dim sChar As String
        Dim sAns As String = ""
 
        lLen = Len(test)
        For lCtr = lLen To 1 Step -1
            sChar = Chr(192 + Asc(Mid(test, lCtr, 1)))
            sAns = sAns & sChar
        Next
 
        TextBox1.Text = sAns

Open in new window

LVL 8
CamilliaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

thigger_ukCommented:
Your code doesn't give you the ASCII of the string (which would be a series of numbers), but a new string which is the original string reversed and with 192 added to the code of each character. For number characters as above (ASCII 48-57) this results in an output with codes in the range 240-249. You should be aware that inputting a string containing letters to your code will cause problems (as adding 192 to eg 'A'=65 gives a number outside the normal 0-255 ASCII range).

To reverse the code:



Dim sCode as String
sCode = TextBox1.Text
 
     Dim lLen As Integer, lCtr As Integer
        Dim sChar As String
        Dim sAns As String = ""
 
        lLen = Len(sCode)
        For lCtr = lLen To 1 Step -1
            sChar = Chr(192 + Asc(Mid(sCode, lCtr, 1)))
            sAns = sAns & sChar
        Next
 
Decoded version now held in sAns.

Open in new window

0
CamilliaAuthor Commented:
let me try
0
CamilliaAuthor Commented:
No, I get this error : Procedure or call is not valid. I get it on sChar:

 Dim sCode As String
        sCode = sAns  ' this is where I encode it (in my code)
        lLen = Len(sCode)
        For lCtr = lLen To 1 Step -1
            sChar = Chr(192 + Asc(Mid(sCode, lCtr, 1)))  ' I get the error heree\
            sAns = sAns & sChar
        Next

0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

thigger_ukCommented:
Sorry - mistake in my code (too much cut'n'paste)

Line 10 should read:
sChar = Chr(Asc(Mid(sCode, lCtr, 1)) - 192)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CamilliaAuthor Commented:
oh, let me try.
0
CamilliaAuthor Commented:
thanks, that worked
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.