R
Rommel6
Unregistered / Unconfirmed
GUEST, unregistred user!
问题所在:
大家帮我看看,为什么在运行界面的Tedit控件上不能正确显示数据
我是向串口发送:55 AA 20
串口返回:55 AA 22 04
55 AA是帧头,用于判断,需要提取数据22和04,分别显示在av1.text和bv1.text中
现在的问题时av1.text显示出22,但是bv1.text什么都不显示,在语句逐行调试过程中
bv1.text的值是04,但是为什么不能显示出来,请知道的人教教我,谢谢。
(ps其中的判断可能有点恶心,我自己也有这样的感觉,目的是为了在接受到不同次数
的消息时在不同列的控件中显示,好像不能用av.text:=''这样的形式,大家有没有
什么技巧可以实现这样的功能,一并告诉我吧。
(下面是我做这个软件的工具和源码)
语言:Delphi 7.0
控件:SPcomm
设计界面和运行界面论坛不能贴图,只能给大家地址了)
http://rommel.91i.net/1.htm
源码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, SPComm, ExtCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Comm1: TComm;
av1: TEdit;
av2: TEdit;
av3: TEdit;
av4: TEdit;
av5: TEdit;
av6: TEdit;
av7: TEdit;
av8: TEdit;
av9: TEdit;
av0: TEdit;
bv1: TEdit;
bv2: TEdit;
bv3: TEdit;
bv4: TEdit;
bv5: TEdit;
bv6: TEdit;
bv7: TEdit;
bv8: TEdit;
bv9: TEdit;
bv0: TEdit;
b_start: TButton;
b_stop: TButton;
cv1: TEdit;
cv2: TEdit;
cv3: TEdit;
cv4: TEdit;
cv5: TEdit;
cv6: TEdit;
cv7: TEdit;
cv8: TEdit;
cv9: TEdit;
cv0: TEdit;
ai1: TEdit;
ai2: TEdit;
ai3: TEdit;
ai4: TEdit;
ai5: TEdit;
ai6: TEdit;
ai7: TEdit;
ai8: TEdit;
ai9: TEdit;
ai0: TEdit;
bi1: TEdit;
bi2: TEdit;
bi3: TEdit;
bi4: TEdit;
bi5: TEdit;
bi6: TEdit;
bi7: TEdit;
bi8: TEdit;
bi9: TEdit;
bi0: TEdit;
ci1: TEdit;
ci2: TEdit;
ci3: TEdit;
ci4: TEdit;
ci5: TEdit;
ci6: TEdit;
ci7: TEdit;
ci8: TEdit;
ci9: TEdit;
ci0: TEdit;
ni1: TEdit;
ni2: TEdit;
ni3: TEdit;
ni4: TEdit;
ni5: TEdit;
ni6: TEdit;
ni7: TEdit;
ni8: TEdit;
ni9: TEdit;
ni0: TEdit;
Bevel1: TBevel;
atime: TEdit;
stime: TEdit;
count: TEdit;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
procedure b_startClick(Sender: TObject);
procedure Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
procedure b_stopClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
icount:integer=0;
implementation
{$R *.dfm}
procedure TForm1.b_startClick(Sender: TObject);
var
buf:array[1..3] of byte;
begin
comm1.StartComm;
sleep(1000);
buf[1]:=byte($55);
buf[2]:=byte($aa);
buf[3]:=byte($20);
comm1.WriteCommData(@buf[1],3);
end;
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
viewstring:string;
head,av,bv,cv,ai,bi,ci,ni,year,mon,date,hour,min,sec:string;
rbuf:array[1..35] of byte;
i:integer;
begin
icount:=icount+1;
viewstring:='';
move(buffer^,pchar(@rbuf)^,bufferlength);
for i:=1 to bufferlength do
viewstring:=viewstring+inttohex(rbuf,2)+'';
head:=copy(viewstring,1,4);
strtoint(head);
begin
av:=copy(viewstring,5,2);
bv:=copy(viewstring,7,2);
cv:=copy(viewstring,9,2);
ai:=copy(viewstring,11,2);
bi:=copy(viewstring,13,2);
ci:=copy(viewstring,15,2);
ni:=copy(viewstring,17,2);
year:=copy(viewstring,19,1);
mon:=copy(viewstring,20,1);
date:=copy(viewstring,21,1);
hour:=copy(viewstring,22,1);
min:=copy(viewstring,23,1);
sec:=copy(viewstring,24,1);
if ((icount mod 10)=1) then
begin
av1.Text:=av;
bv1.Text:=bv;
cv1.Text:=cv;
ai1.Text:=ai;
bv1.Text:=bi;
cv1.Text:=ci;
ni1.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:=viewstring;
end
else if ((icount mod 10)=2) then
begin
av2.Text:=av;
bv2.Text:=bv;
cv2.Text:=cv;
ai2.Text:=ai;
bv2.Text:=bi;
cv2.Text:=ci;
ni2.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=3) then
begin
av3.Text:=av;
bv3.Text:=bv;
cv3.Text:=cv;
ai3.Text:=ai;
bv3.Text:=bi;
cv3.Text:=ci;
ni3.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=4) then
begin
av4.Text:=av;
bv4.Text:=bv;
cv4.Text:=cv;
ai4.Text:=ai;
bv4.Text:=bi;
cv4.Text:=ci;
ni4.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=5) then
begin
av5.Text:=av;
bv5.Text:=bv;
cv5.Text:=cv;
ai5.Text:=ai;
bv5.Text:=bi;
cv5.Text:=ci;
ni5.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=6) then
begin
av6.Text:=av;
bv6.Text:=bv;
cv6.Text:=cv;
ai6.Text:=ai;
bv6.Text:=bi;
cv6.Text:=ci;
ni6.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=7) then
begin
av7.Text:=av;
bv7.Text:=bv;
cv7.Text:=cv;
ai7.Text:=ai;
bv7.Text:=bi;
cv7.Text:=ci;
ni7.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=8) then
begin
av8.Text:=av;
bv8.Text:=bv;
cv8.Text:=cv;
ai8.Text:=ai;
bv8.Text:=bi;
cv8.Text:=ci;
ni8.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=9) then
begin
av9.Text:=av;
bv9.Text:=bv;
cv9.Text:=cv;
ai9.Text:=ai;
bv9.Text:=bi;
cv9.Text:=ci;
ni9.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=0) then
begin
av0.Text:=av;
bv0.Text:=bv;
cv0.Text:=cv;
ai0.Text:=ai;
bv0.Text:=bi;
cv0.Text:=ci;
ni0.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end;
count.Text:=inttostr(icount);
end;
end;
procedure TForm1.b_stopClick(Sender: TObject);
begin
comm1.StopComm;
end;
end.
大家帮我看看,为什么在运行界面的Tedit控件上不能正确显示数据
我是向串口发送:55 AA 20
串口返回:55 AA 22 04
55 AA是帧头,用于判断,需要提取数据22和04,分别显示在av1.text和bv1.text中
现在的问题时av1.text显示出22,但是bv1.text什么都不显示,在语句逐行调试过程中
bv1.text的值是04,但是为什么不能显示出来,请知道的人教教我,谢谢。
(ps其中的判断可能有点恶心,我自己也有这样的感觉,目的是为了在接受到不同次数
的消息时在不同列的控件中显示,好像不能用av.text:=''这样的形式,大家有没有
什么技巧可以实现这样的功能,一并告诉我吧。
(下面是我做这个软件的工具和源码)
语言:Delphi 7.0
控件:SPcomm
设计界面和运行界面论坛不能贴图,只能给大家地址了)
http://rommel.91i.net/1.htm
源码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, SPComm, ExtCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Comm1: TComm;
av1: TEdit;
av2: TEdit;
av3: TEdit;
av4: TEdit;
av5: TEdit;
av6: TEdit;
av7: TEdit;
av8: TEdit;
av9: TEdit;
av0: TEdit;
bv1: TEdit;
bv2: TEdit;
bv3: TEdit;
bv4: TEdit;
bv5: TEdit;
bv6: TEdit;
bv7: TEdit;
bv8: TEdit;
bv9: TEdit;
bv0: TEdit;
b_start: TButton;
b_stop: TButton;
cv1: TEdit;
cv2: TEdit;
cv3: TEdit;
cv4: TEdit;
cv5: TEdit;
cv6: TEdit;
cv7: TEdit;
cv8: TEdit;
cv9: TEdit;
cv0: TEdit;
ai1: TEdit;
ai2: TEdit;
ai3: TEdit;
ai4: TEdit;
ai5: TEdit;
ai6: TEdit;
ai7: TEdit;
ai8: TEdit;
ai9: TEdit;
ai0: TEdit;
bi1: TEdit;
bi2: TEdit;
bi3: TEdit;
bi4: TEdit;
bi5: TEdit;
bi6: TEdit;
bi7: TEdit;
bi8: TEdit;
bi9: TEdit;
bi0: TEdit;
ci1: TEdit;
ci2: TEdit;
ci3: TEdit;
ci4: TEdit;
ci5: TEdit;
ci6: TEdit;
ci7: TEdit;
ci8: TEdit;
ci9: TEdit;
ci0: TEdit;
ni1: TEdit;
ni2: TEdit;
ni3: TEdit;
ni4: TEdit;
ni5: TEdit;
ni6: TEdit;
ni7: TEdit;
ni8: TEdit;
ni9: TEdit;
ni0: TEdit;
Bevel1: TBevel;
atime: TEdit;
stime: TEdit;
count: TEdit;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
procedure b_startClick(Sender: TObject);
procedure Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
procedure b_stopClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
icount:integer=0;
implementation
{$R *.dfm}
procedure TForm1.b_startClick(Sender: TObject);
var
buf:array[1..3] of byte;
begin
comm1.StartComm;
sleep(1000);
buf[1]:=byte($55);
buf[2]:=byte($aa);
buf[3]:=byte($20);
comm1.WriteCommData(@buf[1],3);
end;
procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
viewstring:string;
head,av,bv,cv,ai,bi,ci,ni,year,mon,date,hour,min,sec:string;
rbuf:array[1..35] of byte;
i:integer;
begin
icount:=icount+1;
viewstring:='';
move(buffer^,pchar(@rbuf)^,bufferlength);
for i:=1 to bufferlength do
viewstring:=viewstring+inttohex(rbuf,2)+'';
head:=copy(viewstring,1,4);
strtoint(head);
begin
av:=copy(viewstring,5,2);
bv:=copy(viewstring,7,2);
cv:=copy(viewstring,9,2);
ai:=copy(viewstring,11,2);
bi:=copy(viewstring,13,2);
ci:=copy(viewstring,15,2);
ni:=copy(viewstring,17,2);
year:=copy(viewstring,19,1);
mon:=copy(viewstring,20,1);
date:=copy(viewstring,21,1);
hour:=copy(viewstring,22,1);
min:=copy(viewstring,23,1);
sec:=copy(viewstring,24,1);
if ((icount mod 10)=1) then
begin
av1.Text:=av;
bv1.Text:=bv;
cv1.Text:=cv;
ai1.Text:=ai;
bv1.Text:=bi;
cv1.Text:=ci;
ni1.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:=viewstring;
end
else if ((icount mod 10)=2) then
begin
av2.Text:=av;
bv2.Text:=bv;
cv2.Text:=cv;
ai2.Text:=ai;
bv2.Text:=bi;
cv2.Text:=ci;
ni2.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=3) then
begin
av3.Text:=av;
bv3.Text:=bv;
cv3.Text:=cv;
ai3.Text:=ai;
bv3.Text:=bi;
cv3.Text:=ci;
ni3.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=4) then
begin
av4.Text:=av;
bv4.Text:=bv;
cv4.Text:=cv;
ai4.Text:=ai;
bv4.Text:=bi;
cv4.Text:=ci;
ni4.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=5) then
begin
av5.Text:=av;
bv5.Text:=bv;
cv5.Text:=cv;
ai5.Text:=ai;
bv5.Text:=bi;
cv5.Text:=ci;
ni5.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=6) then
begin
av6.Text:=av;
bv6.Text:=bv;
cv6.Text:=cv;
ai6.Text:=ai;
bv6.Text:=bi;
cv6.Text:=ci;
ni6.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=7) then
begin
av7.Text:=av;
bv7.Text:=bv;
cv7.Text:=cv;
ai7.Text:=ai;
bv7.Text:=bi;
cv7.Text:=ci;
ni7.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=8) then
begin
av8.Text:=av;
bv8.Text:=bv;
cv8.Text:=cv;
ai8.Text:=ai;
bv8.Text:=bi;
cv8.Text:=ci;
ni8.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=9) then
begin
av9.Text:=av;
bv9.Text:=bv;
cv9.Text:=cv;
ai9.Text:=ai;
bv9.Text:=bi;
cv9.Text:=ci;
ni9.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end
else if ((icount mod 10)=0) then
begin
av0.Text:=av;
bv0.Text:=bv;
cv0.Text:=cv;
ai0.Text:=ai;
bv0.Text:=bi;
cv0.Text:=ci;
ni0.Text:=ni;
atime.Text:=year+'年'+mon+'月'+date+'日'+hour+':'+min+':'+sec;
stime.Text:='';
end;
count.Text:=inttostr(icount);
end;
end;
procedure TForm1.b_stopClick(Sender: TObject);
begin
comm1.StopComm;
end;
end.