Results 1 to 5 of 5

Thread: Converting Large String To HEX More Quick Any Help Please

Threaded View

  1. #3
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Converting Large String To HEX More Quick Any Help Please

    Converted my byte array versions to string versions in 10 minutes or so. Writing this post took me longer than making the changes...

    HexStringToString

    Input: any string containing any hex pairs – any single character or invalid character pair is simply ignored

    Output: string where all the hex pairs are translated to their byte equivalent

    This means you can call HexStringToString("41 00garb.age!4200WOOHOO...43.......00") and the output is "ABC", because the only valid hex pairs are: 41, 00, 42, 00, 43, 00


    StringToHexString(Text[, Format[, Separator]][, LowerCase])

    Text: any string

    Format: a string containing a zero pair to represent hex characters and other characters to represent a single row of data
    (default value: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00")

    Separator: a string separator between each Format row
    (default value: vbNewLine)

    Lowercase: True = hex pair characters are lower case (abcdef), False = upper case (ABCDEF)
    (default value: True)


    Okay, this one here is a very powerful function. You can give it almost anything and you get it formatted the way you want. If all you want is to have a space separator between each hex pair, you can call it like this:

    StringToHexString("ABC&abc&åäö", "00", " ", False)

    Output: "41 00 42 00 43 00 26 00 61 00 62 00 63 00 26 00 E5 00 E4 00 F6 00"


    But you can also do this kind of stuff:

    StringToHexString("ABC&abc&åäö", "0000 0000 0000 0000", , False)

    Output:
    Code:
    4100 4200 4300 2600
    6100 6200 6300 2600
    E500 E400 F600

    FINALLY: the code is fast compiled. Running in the IDE it doesn't do that well, there the code is interpreted from P-code on-the-fly and that isn't very efficient.
    Attached Files Attached Files
    Last edited by Merri; Feb 12th, 2011 at 05:05 AM.

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