+ Reply to Thread
Results 1 to 4 of 4

convert raw hex string to ASCII

  1. #1
    Registered User
    Join Date
    06-04-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    3

    convert raw hex string to ASCII

    hello,
    I've been wrestling with this for a while now and need some help.

    I am making a system call to read a serial port as follows:
    status = CommRead(Port, Buffer, Size)

    Where Port is an integer, Buffer is a String and Size is a Long

    I get a string of 20 raw hex values from the device I am reading.
    When I put the Buffer String into a cell, only the numbers that are ASCII characters are displayed.
    I need to convert the raw hex value to an ASCII set then place the 20 values into 20 different rows.

    I've tried indexing into the string, but I always seem to get compile errors. Buffer.Chars(int)
    Side note, my version of VB won't let me declare a Char variable.

    Thanks for any help you can offer.
    Last edited by playitloud; 06-10-2013 at 11:43 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: convert raw hex string to ASCII

    You probably need a FOR/NEXT loop to step through and break down your input string into pairs of bytes which are presumably numerical.

    e.g
    Please Login or Register  to view this content.
    Elegant Simplicity............. Not Always

  3. #3
    Registered User
    Join Date
    06-04-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: convert raw hex string to ASCII

    Quote Originally Posted by AndyLitch View Post
    You probably need a FOR/NEXT loop to step through and break down your input string into pairs of bytes which are presumably numerical.

    e.g
    Please Login or Register  to view this content.
    I see what your code is doing, but the string I get back is not ASCII hex, it needs to be converted from the raw value to something that can be displayed in a cell.

  4. #4
    Registered User
    Join Date
    06-04-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: convert raw hex string to ASCII

    Well, after wrestling around with this a bit more I finally figured it out.
    What are the rules for posting code here?


    Please Login or Register  to view this content.
    Last edited by playitloud; 06-10-2013 at 11:06 AM. Reason: added code

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1