Results 1 to 3 of 3

Thread: Interconversion of characters and bytes

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    35
    For megabyte interconversions of bytes and characters, Chr() and Asc() are pathetically slow (literally hours). The only way I see to get a Byte array efficiently converted into a string is to write the Byte array to a disk file and then read the same disk file into a string variable. That works O.K., but is there a way to execute this Byte array ---> string conversion without having to write a file? If not, there sure ought to be.

    John Fritch

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    I don't know since when, but with vb6 this works:
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
    Dim sText As String
    Dim bAr() As Byte
    Dim i As Integer
        sText = "Frans C"
        bAr = StrConv(sText, vbFromUnicode)
        For i = 0 To UBound(bAr)
            Debug.Print bAr(i)
        Next
        sText = ""
        sText = StrConv(bAr, vbUnicode)
        Debug.Print sText
    End Sub
    I didn't test the speed though.

    [Edited by Frans C on 08-24-2000 at 03:08 PM]

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    35

    Thanks, Frans.

    Frans,

    Thanks for your answer. Before testing your solution, I'd bet "dollars to donuts" that it beats writing to disk hands down. Sorry about misspelling your name in the revision to my other post.

    John Fritch


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