unit DecodeU;
interface
uses Windows, Messages, SysUtils, Variants, Graphics, Forms,
Dialogs, ExtCtrls, Classes, StdCtrls, Controls;
type TDecode=class(TPanel)
private
Ring1:TCombobox;
Ring2:TCombobox;
Ring3:TCombobox;
Ring4:TCombobox;
Ausgabe:TLabel;
protected
procedure myChange(Sender: TObject);
public
constructor Create(AOwner:TComponent);
override;
end;
const FarbString1:
array[0..9]
of String = ('
---','
braun','
rot','
orange','
gelb','
grün','
blau','
violett','
grau','
weiß');
Wert1:
array[0..9]
of integer = (0,1,2,3,4,5,6,7,8,9);
FarbString2:
array[0..9]
of String = ('
schwarz','
braun','
rot','
orange','
gelb','
grün','
blau','
violett','
grau','
weiß');
Wert2:
array[0..9]
of integer = (0,10,20,30,40,50,60,70,80,90);
FarbString3:
array[0..11]
of String = ('
silber','
gold','
schwarz','
braun','
rot','
orange','
gelb','
grün','
blau','
violett','
grau','
weiß');
Wert3:
array[0..11]
of double = (0.01,0.1,1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000);
FarbString4:
array[0..11]
of String = ('
keine','
silber','
gold','
schwarz','
braun','
rot','
orange','
gelb','
grün','
blau','
violett','
grau');
Wert4:
array[0..11]
of double = (20,10,5,0,1,2,0,0,0.50,0.25,0.10,0.05);
implementation
{ TDecode }
constructor TDecode.Create(AOwner: TComponent);
var
i:integer;
begin
inherited Create(AOwner);
width:=600;
height:=200;
Ring1:= TCombobox.create(self);
Ring2:= TCombobox.create(self);
Ring3:= TCombobox.create(self);
Ring4:= TCombobox.create(self);
self.Parent := AOwner
as TWinControl;
Ring1.Parent := Self;
Ring1.width:=100;
Ring1.top:=50;
Ring1.left:=10;
Ring2.Parent := Self;
Ring2.width:=100;
Ring2.top:=50;
Ring2.left:=120;
Ring3.Parent := Self;
Ring3.width:=100;
Ring3.top:=50;
Ring3.left:=230;
Ring4.Parent := Self;
Ring4.width:=100;
Ring4.top:=50;
Ring4.left:=340;
for i:=0
to 11
do
begin
if i<=9
then
begin
Ring1.Items.Add(FarbString1[i]);
Ring2.Items.Add(FarbString2[i]);
end;
Ring3.Items.Add(FarbString3[i]);
Ring4.Items.Add(FarbString4[i]);
end;
Ausgabe:= TLabel.create(self);
Ausgabe.Parent := Self;
Ausgabe.width:=350;
Ausgabe.top:=150;
Ausgabe.left:=150;
ring1.ItemIndex := 0;
ring2.ItemIndex := 1;
ring3.ItemIndex := 2;
ring4.ItemIndex := 1;
ring1.OnChange := myChange;
ring2.OnChange := myChange;
ring3.OnChange := myChange;
ring4.OnChange := myChange;
end;
procedure TDecode.myChange(Sender: TObject);
var
zwischenzahl:double;
begin
zwischenzahl:= (Wert1[ring1.ItemIndex] + Wert2[ring2.ItemIndex]) * Wert3[ring3.ItemIndex];
Ausgabe.Caption:=(FormatFloat('
0.00',zwischenzahl) + '
Ohm Toleranz:'+ (FloatToStr (Wert4[ring4.ItemIndex]))+'
%');
end;
end.