?
Solved

convert from AscW() integer to string

Posted on 2008-11-06
6
Medium Priority
?
377 Views
Last Modified: 2012-08-13
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
0
Comment
Question by:sayeth
  • 2
  • 2
  • 2
6 Comments
 
LVL 4

Expert Comment

by:BToson
ID: 22899871
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
 
LVL 1

Author Comment

by:sayeth
ID: 22899952
Ok, what query can i use to convert string to a integer and be able to convert it back to a string
0
 
LVL 4

Expert Comment

by:BToson
ID: 22900068
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1500 total points
ID: 22900573
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
 
LVL 1

Author Comment

by:sayeth
ID: 22905446
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 22905520
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

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Integration Management Part 2

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question