Aqui mi contribucion a este hilo usando el codigo de este
otro hilo:
Código Delphi
[-]var
Form1: TForm1;
bValor: byte;
function TForm1.IntToBinStr(num: integer): string;
var
i: integer;
begin
for i := 0 to 7 do
Result := IntToStr((num shr i) and 1)+ Result;
end;
procedure TForm1.EnciendeLED;
begin
Label15.Caption := IntToStr(bValor);
if StrToInt(MidStr(IntToBinStr(bValor), 1, 1)) = 0 then
begin
Shape8.Brush.Color := clLime;
Edit8.Text := '0';
end
else
begin
Shape8.Brush.Color := clMoneyGreen;
Edit8.Text := '1';
end;
if StrToInt(MidStr(IntToBinStr(bValor), 2, 1)) = 0 then
begin
Shape7.Brush.Color := clLime;
Edit7.Text := '0';
end
else
begin
Shape7.Brush.Color := clMoneyGreen;
Edit7.Text := '1';
end;
if StrToInt(MidStr(IntToBinStr(bValor), 3, 1)) = 0 then
begin
Shape6.Brush.Color := clLime;
Edit6.Text := '0';
end
else
begin
Shape6.Brush.Color := clMoneyGreen;
Edit6.Text := '1';
end;
if StrToInt(MidStr(IntToBinStr(bValor), 4, 1)) = 0 then
begin
Shape5.Brush.Color := clLime;
Edit5.Text := '0';
end
else
begin
Shape5.Brush.Color := clMoneyGreen;
Edit5.Text := '1';
end;
if StrToInt(MidStr(IntToBinStr(bValor), 5, 1)) = 0 then
begin
Shape4.Brush.Color := clLime;
Edit4.Text := '0';
end
else
begin
Shape4.Brush.Color := clMoneyGreen;
Edit4.Text := '1';
end;
if StrToInt(MidStr(IntToBinStr(bValor), 6, 1)) = 0 then
begin
Shape3.Brush.Color := clLime;
Edit3.Text := '0';
end
else
begin
Shape3.Brush.Color := clMoneyGreen;
Edit3.Text := '1';
end;
if StrToInt(MidStr(IntToBinStr(bValor), 7, 1)) = 0 then
begin
Shape2.Brush.Color := clLime;
Edit2.Text := '0';
end
else
begin
Shape2.Brush.Color := clMoneyGreen;
Edit2.Text := '1';
end ;
if StrToInt(MidStr(IntToBinStr(bValor), 8, 1)) = 0 then
begin
Shape1.Brush.Color := clLime;
Edit1.Text := '0';
end
else
begin
Shape1.Brush.Color := clMoneyGreen;
Edit1.Text := '1';
end ;
end;
procedure TForm1.tbValorChange(Sender: TObject);
begin
bValor := tbValor.position;
EnciendeLED;
end;
Como siempre se aceptan criticas constructivas, destructivas, orientativas y sin sentido!!
¡¡Prohibido desvirtuar este hilo!!