Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Hex in VB

  • 12-01-2004 07:09PM
    #1
    Registered Users, Registered Users 2 Posts: 1,368 ✭✭✭


    Hey guyz,

    I'm using the MSComm component in VB for communication with a serial device. The serial device operates on hex commands. I've tried adding a text field to my app. and directly writing in the hex commands. The problem is when I enter the following hex value:

    010A00000000020108F7

    VB sees this as a string and not a series of hex values. Does anyone know how to convert from the Hex string to the actual hex value in VB

    Any help appreciated,
    thanks


Comments

  • Registered Users, Registered Users 2 Posts: 79 ✭✭tendofan


    Maybe you need to Dim a string and each hex byte you want to send, you need to convert it to a character and add it to the string.

    Dim sCommand as String

    'To put the command 01 0A 00 into the string..

    sCommand = sCommand & Chr(&H01)
    sCommand = sCommand & Chr(&H0A)
    sCommand = sCommand & Chr(&H00)

    then set the data for the comm control to sCommand.

    Tendofan


  • Closed Accounts Posts: 4 Scof


    Are you using VB6?

    The Hex$ function should do what your after...


Advertisement