procedure TForm1.Button1Click(Sender: TObject);<br>var<br>i:variant;<br>sbuf:array[1..6] of byte;<br>begin<br>i:='$'+panel1.caption;<br>sbuf[1]:=IntToStr(i);<br>end;<br>
我想通过panel或者edit输入字符串,然后再通过串口发数据<br>所以,必须将字符串变为字节类型<br>对楼上的更正一下<br>最简单的应是<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>sbuf:array[1..6] of byte;<br>begin<br>sbuf[1]:=strtoint('$'+panel1.Caption);<br>end;<br>接受答案