Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to convert BYTE to String

how to convert BYTE to String

Scheduled Pinned Locked Moved C / C++ / MFC
c++questioncsharpwinformshelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    doneirik
    wrote on last edited by
    #1

    Hi I´m doing some basic serial communication vith Visual C++ .NET. Reading from the serial port with the ReadFile command: BYTE Byte; ReadFile (hPort, &Byte, 1, &dwBytesTransferred, 0); I have some problems displaying what I read....With the "cout" command this worked fine: cout< However, with a Windows Forms Appl. I need to output the readout with `this->Textbox1->Text = Byte;` With this I get an error message, saying "cannot convert from BYTE to String" How can I convert this BYTE variable in order to make it compatible?` regards, doneirik

    M D 2 Replies Last reply
    0
    • D doneirik

      Hi I´m doing some basic serial communication vith Visual C++ .NET. Reading from the serial port with the ReadFile command: BYTE Byte; ReadFile (hPort, &Byte, 1, &dwBytesTransferred, 0); I have some problems displaying what I read....With the "cout" command this worked fine: cout< However, with a Windows Forms Appl. I need to output the readout with `this->Textbox1->Text = Byte;` With this I get an error message, saying "cannot convert from BYTE to String" How can I convert this BYTE variable in order to make it compatible?` regards, doneirik

      M Offline
      M Offline
      Mahendra_786
      wrote on last edited by
      #2

      Try this: char buff[3] = ""; sprintf(buff, "%X", Byte); // Display in hex (or choose whatever format you prefer) this->Textbox1->Text = buff; Hope it works! Regards Mahendra

      1 Reply Last reply
      0
      • D doneirik

        Hi I´m doing some basic serial communication vith Visual C++ .NET. Reading from the serial port with the ReadFile command: BYTE Byte; ReadFile (hPort, &Byte, 1, &dwBytesTransferred, 0); I have some problems displaying what I read....With the "cout" command this worked fine: cout< However, with a Windows Forms Appl. I need to output the readout with `this->Textbox1->Text = Byte;` With this I get an error message, saying "cannot convert from BYTE to String" How can I convert this BYTE variable in order to make it compatible?` regards, doneirik

        D Offline
        D Offline
        doneirik
        wrote on last edited by
        #3

        Thanks, it worked.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups