function TForm1.HexStrToByte(HesStr: String): Byte;
var
iLen: Integer;
begin
Result := 0;
iLen := length(HesStr);
if iLen <> 2 then Exit;
If not (HesStr[1] in ['0'..'9', 'A'..'F', 'a'..'f']) Then Exit;
If not (HesStr[2] in ['0'..'9', 'A'..'F', 'a'..'f']) Then Exit;
Result := StrToInt('$' + HesStr);
end;
上面这个函数更简洁一些!