Results 1 to 2 of 2

Thread: vb 2012 convertall?

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    10

    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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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
  •  



Click Here to Expand Forum to Full Width