Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Hex in VB

Options
  • 12-01-2004 7:09pm
    #1
    Registered Users Posts: 1,366 ✭✭✭


    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 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