Einzelnen Beitrag anzeigen

Benutzerbild von p80286
p80286

Registriert seit: 28. Apr 2008
Ort: Stolberg (Rhl)
6.659 Beiträge
 
FreePascal / Lazarus
 
#16

Re: Text in Dualzahlen umwandeln

  Alt 24. Mär 2010, 12:41
versuch es doch einmal mit dieser Simpellösung:
Delphi-Quellcode:
function Byte2Bin(inbyte:byte):string;
const
  bina:array [0..1] of char=('0','1');
begin
  result:=' ';
  result[1]:=bina[(inbyte shr 7) and $01];
  result[2]:=bina[(inbyte shr 6) and $01];
  result[3]:=bina[(inbyte shr 5) and $01];
  result[4]:=bina[(inbyte shr 4) and $01];
  result[5]:=bina[(inbyte shr 3) and $01];
  result[6]:=bina[(inbyte shr 2) and $01];
  result[7]:=bina[(inbyte shr 1) and $01];
  result[8]:=bina[(inbyte and $01)];
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  i : integer;
begin
  for i:=1 to length(label1.caption) do
    label2.Caption:=label2.Caption+' '+Byte2Bin(byte(label1.Caption[i]));
end;
Gruß
K-H
Programme gehorchen nicht Deinen Absichten sondern Deinen Anweisungen
R.E.D retired error detector
  Mit Zitat antworten Zitat