convert from AscW() integer to string

Dim A As String = "pimp"
        Dim B As Integer
        Dim C As String

        B = AscW(A)

        ' how do i convert B back to the string pimp
        C = 'B
LVL 1
sayethAsked:
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.

BTosonCommented:
You can't.  Using a query such as that will only return the character code for the first letter.
ChrW(B) will demonstrate this and return "p".
0
sayethAuthor Commented:
Ok, what query can i use to convert string to a integer and be able to convert it back to a string
0
BTosonCommented:
Not sure what you are intending to do but something like the code below may work.
Unfortunately I can't think of a better way of doing it right at the moment.
Dim CharacterCodes As New List(Of Integer)
For Each Character In A.ToCharArray
	CharacterCodes.Add(AscW(Character))
Next
 
Dim RebuiltStringWriter As New System.IO.StringWriter
For Each CharacterCode In CharacterCodes
	RebuiltStringWriter.Write(ChrW(CharacterCode))
Next
Dim RebuiltString = RebuiltStringWriter.ToString

Open in new window

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Mike TomlinsonMiddle School Assistant TeacherCommented:
What do you want to do with "B"?....

Maybe you need a Byte Array?

        Dim A As String = "pimp"
        Dim bytes() As Byte = Convert.FromBase64String(A)
        Dim C As String = Convert.ToBase64String(bytes)
        MessageBox.Show(A & " = " & C)
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
sayethAuthor Commented:
sorry i had a meeting. Ok
What do you want to do with "B"?....
Idle Mind:  I m using a predefine string in my interface and i can only store integer. so i need the store integer convert back to a string to show the user if they go back to that interface or not.  
If it is not possible, i will do it the the long way, using if else statement or case statement

0
Mike TomlinsonMiddle School Assistant TeacherCommented:
I'll go with "not possible"...at least not using anything built-in to the .Net framework.

Could you explain more about your interface and the storing of the value?...that doesn't make any sense at the moment.
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.

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.