我通过串口通信组件能够接收下位机发送的数据!
 但我 想在listbox中能够时时接收下位机的消息!   我用了一个timer控件,请指教一下(每一步的对错)
 procedure TForm1.Timer1Timer(Sender: TObject);
var a,b,i,j,k,l,m:integer;
type
   range=array[0..15]of integer;
var  rang:range;
begin
receive:=comm1.Input;           //读端口数据放在receive中i:=strtointdef(receive,-1);    //将string类型的数据receive转换为整形的
for  j:=0 to 15 do            //给数组赋值
rang[j]:=j;
k:=i+1;if (i>=0)and(i<9) then          //判断in 01~09 还是 in 10~16
for l:=0 to 15 do
begin
if i=rang[l] then
begin
for b :=0 to 15 do
liu2.ListBox1.Items[b]:='IN    '+inttostr(b+1)+  '    输入为0';
liu2.ListBox1.Items[i]:='IN    '+inttostr(k)+'    输入为1';
liu2.listbox1.Refresh;end;
end;if (8<i )and (i<16) then
for m:=0 to 15 do
begin
if i=rang[m] then
begin
for a:=0 to 15 do
liu2.ListBox1.Items[a]:='IN    '+inttostr(a+1)+  '    输入为0';
liu2.ListBox1.Items[i]:='IN    '+inttostr(K)+'    输入为1';end;
end;
end;