Link to home
Start Free TrialLog in
Avatar of sayeth
sayeth

asked on

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
Avatar of BToson
BToson
Flag of United Kingdom of Great Britain and Northern Ireland image

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".
Avatar of sayeth
sayeth

ASKER

Ok, what query can i use to convert string to a integer and be able to convert it back to a string
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

ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sayeth

ASKER

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

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.