首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

Delphi 7 开启COMM有关问题

2012-11-15 
Delphi 7 开启COMM问题,本人新手,打算自做一个类似串口助手的小软件,想用combobox控件来进行选择COMX口,进

Delphi 7 开启COMM问题,
本人新手,打算自做一个类似串口助手的小软件,想用combobox控件来进行选择COMX口,进行通讯,可是每次开启comm的时候总是引发异常,,求指教,代码如下。。感谢额。[code=Delphi(Pascal)][/code]


unit Form;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, SPComm;

type
  TForm1 = class(TForm)
  Group_Communicate: TGroupBox;
  Box_Serial: TComboBox;
  Label1: TLabel;
  Label2: TLabel;
  Box_Baud: TComboBox;
  Btn_Open: TBitBtn;
  Btn_Cancel: TBitBtn;
  Group_Receive: TGroupBox;
  L_R_Auto: TCheckBox;
  L_R_Hex: TCheckBox;
  Group_Send: TGroupBox;
  L_S_Hex: TCheckBox;
  L_S_Auto: TCheckBox;
  L_S_Clear: TCheckBox;
  Mem_Display: TMemo;
  Mem_Send: TMemo;
  Btn_Send: TBitBtn;
  L_Help: TLabel;
  Label4: TLabel;
  Label_Note: TLabel;
  Comm: TComm;
  Label5: TLabel;
  Label6: TLabel;
  Label3: TLabel;
  Label7: TLabel;
  Label8: TLabel;
  procedure Btn_OpenClick(Sender: TObject);
  private
  { Private declarations }
  public
  { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Btn_OpenClick(Sender: TObject);
begin

  if Box_Serial.ItemIndex = 0 then
  comm.CommName:='COM1'
  else if Box_Serial.ItemIndex = 1 then
  comm.CommName:='COM2'
  else if Box_Serial.ItemIndex = 2 then
  comm.CommName:='COM3'
  else if Box_Serial.ItemIndex = 3 then
  comm.CommName:='COM4';

  {根据选项,设置串口}
  comm.BaudRate:=strtoint(Box_Baud.Text);
  {设置波特率}
  comm.StartComm;
  {开启串口}


end;

end.




[解决办法]
你问的是什么问题?异常 是什么异常?
[解决办法]
汗。。结贴吧

热点排行