how to convert BYTE to String
-
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
-
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
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
-
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