Ver Mensaje Individual
  #8  
Antiguo 17-06-2008
[FGarcia] FGarcia is offline
Miembro Premium
 
Registrado: sep 2005
Ubicación: Cordoba, Veracruz, México
Posts: 1.123
Reputación: 22
FGarcia Va por buen camino
Aqui mi contribucion a este hilo usando el codigo de este otro hilo:

Código Delphi [-]
//Declaramos una variable de tipo byte
var
  Form1: TForm1;
  bValor: byte;

//Creamos esta funcion para convertir el valor entero en una cadena binaria
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;
 
//Esta es la funcion de los led y shapes
procedure TForm1.EnciendeLED;
begin
  //esta etiqueta es nueva
  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;

//Cuando cambia el valor de TrackBar al cual llamamos tbValor
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!!
Responder Con Cita