N
nhlong320
Unregistered / Unconfirmed
GUEST, unregistred user!
我做了一个读卡系统它读的码子正确,若读取一张卡显示02 31 41 32 42 , 可是我是用的spcomm,怎样才能让它转换显示为十进制的6432,其中02表示空格不用管,小生笨,请大侠救我!最好能给我写段源代码实现,可以发到我的邮箱nhlong320@163.com
源程序在下:procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
i,j:integer;
Hex:integer;
viewstring,wiewstring:string; //串口接受字符串
rbuf,sbuf:array[1..5] of byte; //信息所占缓存
begin
button2.Visible:=false;
viewstring:='';
for i:=1 to 5 do
begin
rbuf:=0;
end;
move(buffer^,pchar(@rbuf)^,5); //Copies bytes from a source to a destination.
for i:=1 to 5 do
begin
viewstring:=viewstring+inttohex(rbuf,2)+' ';
sbuf:=hextoint(viewstring);
end;
viewstring:='接受'+viewstring;
memo1.lines.add(viewstring);
//memo2.lines.add()///////在它当中加入十进制6432
源程序在下:procedure TForm1.Comm1ReceiveData(Sender: TObject; Buffer: Pointer;
BufferLength: Word);
var
i,j:integer;
Hex:integer;
viewstring,wiewstring:string; //串口接受字符串
rbuf,sbuf:array[1..5] of byte; //信息所占缓存
begin
button2.Visible:=false;
viewstring:='';
for i:=1 to 5 do
begin
rbuf:=0;
end;
move(buffer^,pchar(@rbuf)^,5); //Copies bytes from a source to a destination.
for i:=1 to 5 do
begin
viewstring:=viewstring+inttohex(rbuf,2)+' ';
sbuf:=hextoint(viewstring);
end;
viewstring:='接受'+viewstring;
memo1.lines.add(viewstring);
//memo2.lines.add()///////在它当中加入十进制6432