ComboBox应用的有关问题
ComboBox应用的问题
代码如下,
procedure SendData_Bit2;
var
DataStr2:String;
DataInt2:Integer;
i:Integer;
selLine:Integer;
selStr:string;
begin
DataStr2:=Form1.Edit2.Text;
i:=StrToInt(DataStr2); //String to Integer;
selStr:=ComboBox2.Items[ComboBox2.ItemIndex];
selLine:=ComboBox2.Items.Indexof(selStr);
case selLine of
0:
begin
DataInt2:=i+200;
end;
1:
begin
if i <11 then DataInt2:=i
else if i > 11 then DataInt2 := (i div 100)+100;
end;
end;
ViewStr:='';
CommFlag:=True;
input[1]:=DataInt2;
if not Form1.Comm1.WriteCommData(@input[1],1)then
begin
CommFlag:=False;
end;
ViewStr:='Send'+''+DataStr2;
Form1.Memo1.Lines.Add(ViewStr);
if not CommFlag then messagedlg('sending falied' ,mterror,[mbyes],0);
end;
------解决方案--------------------
procedure SendData_Bit2;
不是
procedure TForm1.SendData_Bit2;
你这是一个独立的过程,不是你的窗口类的一个方法,ComboBox2是你的窗体类的成员。你在独立的过程里面去找一个ComboBox2当然找不到
代码如下,
procedure SendData_Bit2;
var
DataStr2:String;
DataInt2:Integer;
i:Integer;
selLine:Integer;
selStr:string;
begin
DataStr2:=Form1.Edit2.Text;
i:=StrToInt(DataStr2); //String to Integer;
selStr:=ComboBox2.Items[ComboBox2.ItemIndex];
selLine:=ComboBox2.Items.Indexof(selStr);
case selLine of
0:
begin
DataInt2:=i+200;
end;
1:
begin
if i <11 then DataInt2:=i
else if i > 11 then DataInt2 := (i div 100)+100;
end;
end;
ViewStr:='';
CommFlag:=True;
input[1]:=DataInt2;
if not Form1.Comm1.WriteCommData(@input[1],1)then
begin
CommFlag:=False;
end;
ViewStr:='Send'+''+DataStr2;
Form1.Memo1.Lines.Add(ViewStr);
if not CommFlag then messagedlg('sending falied' ,mterror,[mbyes],0);
end;
------解决方案--------------------
procedure SendData_Bit2;
不是
procedure TForm1.SendData_Bit2;
你这是一个独立的过程,不是你的窗口类的一个方法,ComboBox2是你的窗体类的成员。你在独立的过程里面去找一个ComboBox2当然找不到