?
Solved

Hex to String

Posted on 2004-11-09
5
Medium Priority
?
495 Views
Last Modified: 2010-04-23
I am trying to convert a Hex string to a character string. The value is being converted to Hexidecimal by the Hex() function but I have been unable to find a similar function to convert it back from Hexidecimal to String. Could anyone shed any light?

The code used to "encode" it is:

 For Each sChar In Value
                sRet += Hex(Asc(sChar)).ToString
Next


Example:

I have this string:

546869732069732061207465737421

and I want to convert it back to the original string:

This is a test!




Thanks,

M@
0
Comment
Question by:willcode4coffee
  • 4
5 Comments
 
LVL 3

Expert Comment

by:eekj
ID: 12539539
Dim OutStr As String = Hex(Int32.Parse("546869732069732061207465737421"))
0
 
LVL 3

Expert Comment

by:eekj
ID: 12539557
whoops i didnt read your question properly... duh
0
 
LVL 4

Author Comment

by:willcode4coffee
ID: 12539581
No problem. I can find lots of examples of how to get it to hex, but none on how to get it back.

M@
0
 
LVL 3

Accepted Solution

by:
eekj earned 2000 total points
ID: 12540014
Dim before As String = "546869732069732061207465737421"
Dim ret As String = ""
Dim i As Int16 = 0

For i = 0 To before.Length - 1
     ret = ret + (ChrW(Integer.Parse(before.Substring(i, 2), System.Globalization.NumberStyles.HexNumber)))
     i = i + 1
 Next
 MsgBox(ret)

"This is a Test!"
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Screencast - Getting to Know the Pipeline
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

578 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