积极答复者
现在TEXT 控件上显示接收到的是数字,如何进行判断下,让TEXT显示字符呢?

问题
-
哈喽,哈喽
亲爱的朋友们,过来啦
我现在接受了一串数字,但是我想做一个判断,就是当S= {0x02,0x30,0x30,0x46,0x46,0x30,0x03}时,TEXT上显示,马达正在原点中,这应该如何写代码呢?
private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) { string B01 = "马达正在原点中"; //string B02 = ""; /* byte[] data = Convert.FromBase64String(serialPort1.ReadLine()); textBox1.Text = Encoding.Unicode.GetString(data);*/ serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived); string s = ""; int count = serialPort1.BytesToRead; byte[] data = new byte[count]; serialPort1.Read(data, 0, count); foreach (byte item in data) { s += Convert.ToString(item); //B02 += Convert.ToString(item); } this.Invoke(new MethodInvoker(delegate { this.textBox1.Text = s; }));
答案
-
Hi,
欢迎在MSDN论坛发帖。
请不要重复发相同的帖子。
我将合并这两个帖子。
Best Regards,
Hart
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
- 已标记为答案 绿绿山水 2018年1月15日 1:15
全部回复
-
Hi,
欢迎在MSDN论坛发帖。
请不要重复发相同的帖子。
我将合并这两个帖子。
Best Regards,
Hart
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
- 已标记为答案 绿绿山水 2018年1月15日 1:15