Thema: Delphi bin2dec

Einzelnen Beitrag anzeigen

Daniel B
(Gast)

n/a Beiträge
 
#10
  Alt 6. Apr 2003, 08:35
Moin Christian,
Zitat von Christian Seehase:
  if (length(AsValue) < 1) or (length(AsValue) > 32) then
Das hat mich auf eine Idee gebracht.
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  bByte: Byte;
  iErgebnis: Integer;
begin
  iErgebnis := 0;
  bByte := StrToInt(Edit1.Text);
  if (bByte and 1) <> 0 then
    iErgebnis := iErgebnis + 1;
  if (bByte and 2) <> 0 then
    iErgebnis := iErgebnis + 2;
  if (bByte and 4) <> 0 then
    iErgebnis := iErgebnis + 4;
  if (bByte and 8) <> 0 then
    iErgebnis := iErgebnis + 8;
  if (bByte and 16) <> 0 then
    iErgebnis := iErgebnis + 16;
  if (bByte and 32) <> 0 then
    iErgebnis := iErgebnis + 32;
  if (bByte and 64) <> 0 then
    iErgebnis := iErgebnis + 64;
  if (bByte and 128) <> 0 then
    iErgebnis := iErgebnis + 128;
  ShowMessage(IntToStr(iErgebnis));
end;
Grüsse, Daniel
  Mit Zitat antworten Zitat