I
inzaghi_delphi
Unregistered / Unconfirmed
GUEST, unregistred user!
这是一段接收串口回传的16进制数据的程序
procedure TF_main.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);(我用了spcomm控件)
var
tmpArray:array[0..4096] of Integer;
i: dword;
tmpStr:string;
pStrChar;
HexStr:string;
begin
pStr:=Buffer;
tmpStr:=string(pStr);
Dec(PStr);
for i:=4 to 5 do
begin
inc(PStr);
tmpArray:=Byte(PSTR^);
Memo2.Lines.Add(IntToHEX(Ord(tmpArray),2));
HexStr:=Memo2.Lines.Text;//问题好像在这里,memo2的数据为16进制
end;
edit4.Text:=Format('%d',[StrtoInt('$'+HexStr)]);
//StrtoInt('$'+这里好像必须为integer)
exit;
end;
各位大虾程序该怎么改????
procedure TF_main.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);(我用了spcomm控件)
var
tmpArray:array[0..4096] of Integer;
i: dword;
tmpStr:string;
pStrChar;
HexStr:string;
begin
pStr:=Buffer;
tmpStr:=string(pStr);
Dec(PStr);
for i:=4 to 5 do
begin
inc(PStr);
tmpArray:=Byte(PSTR^);
Memo2.Lines.Add(IntToHEX(Ord(tmpArray),2));
HexStr:=Memo2.Lines.Text;//问题好像在这里,memo2的数据为16进制
end;
edit4.Text:=Format('%d',[StrtoInt('$'+HexStr)]);
//StrtoInt('$'+这里好像必须为integer)
exit;
end;
各位大虾程序该怎么改????