我想向硬件输入二进制数据。
我是
  var
   tempword:array[0..6] of variant;
begin
       tempword[0]:=Byte(secondof(now));
       //mscomm1.Output:=tempword;
       tempword[1]:=Byte(minuteof(now));
       //mscomm1.Output:=tempword;
       tempword[2]:=Byte(hourof(now));
      // mscomm1.Output:=tempword;
       tempword[3]:=Byte(dayof(now));
       //mscomm1.Output:=tempword;
       tempword[4]:=Byte(monthof(now));
       //mscomm1.Output:=tempword;
       tempword[5]:=Byte(dayofweek(now));
       //mscomm1.Output:=tempword;
       tempword[6]:=Byte(yearof(now)-2000);
       //mscomm1.Output:=tempword;
       for i:=0 to 6 do
       begin
           mscomm1.Output:=tempword[i];
       end;
end;
我的写法对吗?为什么系统总是提示“属性值不匹配”啊!
哪位大虾能帮帮芒解决一下?

解决方案 »

  1.   

    来检分了
    mscomm1的inputmode设置为comInputModeText
    for i:=0 to 6 do
           begin
               mscomm1.Output:=chr(tempword[i]);
           end;
      

  2.   

    mscomm1的inputmode设置为comInputModeText
    不是设置的接收文件的方式吗?
    它对输出文件也可以吗?
      

  3.   

    对是这样的,但如果不设置成comInputModeText,接收上来无法识别。因为发送
    for i:=0 to 6 do
           begin
               mscomm1.Output:=chr(tempword[i]);
           end;
     是字符形式的。还有tempword:array[0..6] of variant;改成tempword:array[0..6] of byte;
      

  4.   

    收/发串口数据注意是采用二进制还是文本格式,你可以参考VB下关于MSCOMM的文档