locked
Name vbFromUnicode and Vbunicode not Declared.

    Question

  •   Hi All

    I have upgraded Huffmann coding which is in Vb6 to VB.net I got the Vb 6 Huffmann csding from Planet source.
    I am using Visual Basic 2005,,
    These are the four errors I couldnt resolve
    Please Help me in this case. I am lacking time > Thank you very much in Advance.


    Error 1 Name 'vbFromUnicode' is not declared. C:\Documents and Settings\ct103.LAB103-121\My Documents\Visual Studio 2005\Projects\clsHuffman.vb 436 74 HuffmanExample
    Error 2 Name 'vbUnicode' is not declared. C:\Documents and Settings\ct103.LAB103-121\My Documents\Visual Studio 2005\Projects\clsHuffman.vb 443 84 HuffmanExample
    Error 3 Name 'vbFromUnicode' is not declared. C:\Documents and Settings\ct103.LAB103-121\My Documents\Visual Studio 2005\Projects\clsHuffman.vb 453 74 HuffmanExample
    Error 4 Name 'vbUnicode' is not declared. C:\Documents and Settings\ct103.LAB103-121\My Documents\Visual Studio 2005\Projects\clsHuffman.vb 460 84 HuffmanExample


    Public
    Function DecodeString(ByRef Text As String) As String

    Dim ByteArray() As Byte

    'Convert the string to a byte array

    'UPGRADE_ISSUE: Constant vbFromUnicode was not upgraded. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="55B59875-9A95-4B71-9D6A-7C294BF7139D"'

    'UPGRADE_TODO: Code was upgraded to use System.Text.UnicodeEncoding.Unicode.GetBytes() which may not have the same behavior. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="93DD716C-10E3-41BE-A4A8-3BA40157905B"'

    ByteArray = System.Text.UnicodeEncoding.Unicode.GetBytes(StrConv(Text, vbFromUnicode))

    'Compress the byte array

    Call DecodeByte(ByteArray, Len(Text))

    'Convert the compressed byte array to a string

    'UPGRADE_ISSUE: Constant vbUnicode was not upgraded. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="55B59875-9A95-4B71-9D6A-7C294BF7139D"'

    DecodeString = StrConv(System.Text.UnicodeEncoding.Unicode.GetString(ByteArray), vbUnicode)

    End Function

    Public Function EncodeString(ByRef Text As String) As String

    Dim ByteArray() As Byte

    'Convert the string to a byte array

    'UPGRADE_ISSUE: Constant vbFromUnicode was not upgraded. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="55B59875-9A95-4B71-9D6A-7C294BF7139D"'

    'UPGRADE_TODO: Code was upgraded to use System.Text.UnicodeEncoding.Unicode.GetBytes() which may not have the same behavior. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="93DD716C-10E3-41BE-A4A8-3BA40157905B"'

    ByteArray = System.Text.UnicodeEncoding.Unicode.GetBytes(StrConv(Text, vbFromUnicode))

    'Compress the byte array

    Call EncodeByte(ByteArray, Len(Text))

    'Convert the compressed byte array to a string

    'UPGRADE_ISSUE: Constant vbUnicode was not upgraded. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="55B59875-9A95-4B71-9D6A-7C294BF7139D"'

    EncodeString = StrConv(System.Text.UnicodeEncoding.Unicode.GetString(ByteArray), vbUnicode)

    End Function



    Thank you very much for reading this

    Monday, June 30, 2008 12:02 PM

Answers

  • Lisa,  something like this perhaps:

    Public Function DecodeString (ByVal Text As StringAs String 
        'Convert the string to a byte array  
        Dim ByteArray() As Byte = Encoding.Ascii.GetBytes(Text)  
         
        'Compress the byte array  
        DecodeByte(ByteArray, ByteArray.Length)  
     
        'Convert the compressed byte array to a string  
        Return Encoding.Default.GetString(ByteArray)  
    End Function 
     
    Public Function EncodeString (ByVal Text As StringAs String 
        'convert the string to a byte array  
        Dim ByteArray() As Byte = Encoding.Ascii.GetBytes(Text)  
     
        'Compress the byte array  
        EncodeByte(ByteArray, ByteArray.Length)  
     
        'Convert the compressed byte array to a string  
        Return Encoding.Default.GetString(ByteArray)  
    End Function 
          

    Anyway, that should be close :)

    HTH
    Tom Shelton
    Tuesday, July 01, 2008 8:59 PM