|
-
Apr 7th, 2013, 08:16 PM
#1
Thread Starter
New Member
vb 2012 convertall?
So I was trying to translate this code from vb 2008 to vb 2012 and I found some surprises...
Dim text As String = u
Dim bytes As Byte() = Encoding.ASCII.GetBytes(text)
Dim hex As String() = Array.ConvertAll(bytes, Function(b) b.ToString("X2"))
Dim output As String = String.Join(String.Empty, hex)
There is no Encoding.ASCII in vb 2012, I replaced that to
Dim bytes As Byte() = Encoding.UTF8.GetBytes(text)
But I have no idea how do I convert the bytes to a string? there is no convertAll function in vb2012... The main idea is converting any text value entered in textboxt1 to it hexadecimal value and display it in a textblock1 (or label but there are no labels in vb2012). Same thing that this online tool http://www.swingnote.com/tools/texttohex.php can do.
-
Apr 7th, 2013, 09:40 PM
#2
Re: vb 2012 convertall?
That code will work as is in VB 2012. There is virtually no code that you can write in any version of VB.NET that will not work in later versions. Both the ASCII property of the System.Text.Encoding class and the ConvertAll method of the Array class are alive and well in VB 2012 or, more correctly, .NET 4.5. If you're having issues then something else is going on.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|