Hola Lizeth.
Código Delphi
[-]
...
type
TArrayOfByte= array of Byte;
procedure HexaToByte(Cadena: string; var Vec: TArrayOfByte);
var
i,p: Integer;
s: string;
begin
if Cadena[1] = ':' then
Delete(Cadena, 1, 1);
if Cadena[Length(Cadena)] <> ':' then
Cadena:= Cadena + ':';
i:= 1;
repeat
p:= Pos(':', Cadena);
s:= Copy(Cadena, 1, p-1);
if p > 0 then
begin
SetLength(Vec, i+1);
try
Vec[i]:= StrToInt('$'+ s);
except
raise Exception.Create('Error, ( '+s+' ) no es un número hexadecimal');
end;
Inc(i);
Delete(Cadena, 1, p);
end;
until p = 0;
end;
...
Llamada:
Código Delphi
[-]
procedure TForm1.Button1Click(Sender: TObject);
var
Vec: TArrayOfByte;
i: Integer;
begin
HexaToByte('01:02:03:04:0C:0A:0B:FF:40',Vec);
Memo1.Clear;
for i:= Low(Vec) to High(Vec) do
Memo1.Lines.Add(IntToStr(Vec[i]))
end;
Un saludo.