以下是想对SPCOMM 进行动态设置属性,可是由于类型不相同,该怎么转换???  comm1.CommName:=combobox1.text;  //端口号
  comm1.BaudRate:=combobox2.text;  //波特率
  comm1.ByteSize:=combobox3.text;  //数据位
  comm1.StopBits:=combobox4.text;  //停止位
  comm1.Parity:=combobox5.text;    //校验码

解决方案 »

  1.   

    下面是个例子:procedure Tform1.BitBtn2Click(Sender: TObject);
    begin
      comm1.commname:=combobox1.Text;
      comm1.StartComm;
      comm1.BaudRate:=strtoint(combobaudrate.Text);
      case combodatabits.ItemIndex of
       0:comm1.ByteSize:=_5;
       1:comm1.ByteSize:=_6;
       2:comm1.ByteSize:=_7;
       3:comm1.ByteSize:=_8;
      end;
      case combostopbits.ItemIndex of
       0:comm1.stopbits:=_1;
       1:comm1.stopbits:=_1_5;
       2:comm1.stopbits:=_2;
      end;
      case comboparity.ItemIndex of
       0:comm1.Parity:=None;
       1:comm1.Parity:=Odd;
       2:comm1.Parity:=Even;
       3:comm1.Parity:=Mark;
       4:comm1.Parity:=Space;
      end;
      if comboparity.ItemIndex=0 then comm1.ParityCheck:=false
      else comm1.paritycheck:=true;
      BitBtn2.Enabled:=false;
    end;