Einzelnen Beitrag anzeigen

Gehstock

Registriert seit: 28. Jan 2006
Ort: Görlitz / Sachsen
489 Beiträge
 
Delphi 2007 Professional
 
#16

Re: Wie kann ich das rechnen

  Alt 19. Aug 2006, 11:13
Dsa klappt so net immer wenn ich irgendwas verändere klappt was anderes wieder nicht

deswegen mal komplett nich meckern binn noch nicht fertig mit dem optimieren der Normwiderstände

Delphi-Quellcode:
procedure TForm2.btn_executeClick(Sender: TObject);
var
wert : string;
widerstand : string;
tolerance: string;
prozent: extended;

begin
if rb_4rings.Checked then begin ++++++wollte ich umstellen (case) tut dann aber auch dumm
wert := floattostr(((cb_ring1.ItemIndex+1)*10) + cb_ring2.ItemIndex);
if cb_ring3.ItemIndex = 0 then widerstand := floattostr((strtofloat(wert)/100));
if cb_ring3.ItemIndex = 1 then widerstand := floattostr((strtofloat(wert)/10));
if cb_ring3.ItemIndex = 2 then widerstand := floattostr((strtofloat(wert)*1));
if cb_ring3.ItemIndex = 3 then widerstand := floattostr((strtofloat(wert)*10));
if cb_ring3.ItemIndex = 4 then widerstand := floattostr((strtofloat(wert)*100));
if cb_ring3.ItemIndex = 5 then widerstand := floattostr((strtofloat(wert)*1000));
if cb_ring3.ItemIndex = 6 then widerstand := floattostr((strtofloat(wert)*10000));
if cb_ring3.ItemIndex = 7 then widerstand := floattostr((strtofloat(wert)*100000));
if cb_ring3.ItemIndex = 8 then widerstand := floattostr((strtofloat(wert)*1000000));
if cb_ring3.ItemIndex = 9 then widerstand := floattostr((strtofloat(wert)*10000000));
end;

if rb_5rings.Checked then begin
wert := floattostr(((cb_ring1.ItemIndex+1)*100) + ((cb_ring2.ItemIndex)*10) + (cb_ring53.ItemIndex));
if cb_ring54.ItemIndex = 0 then widerstand := floattostr((strtofloat(wert)/100));
if cb_ring54.ItemIndex = 1 then widerstand := floattostr((strtofloat(wert)/10));
if cb_ring54.ItemIndex = 2 then widerstand := floattostr((strtofloat(wert)*1));
if cb_ring54.ItemIndex = 3 then widerstand := floattostr((strtofloat(wert)*10));
if cb_ring54.ItemIndex = 4 then widerstand := floattostr((strtofloat(wert)*100));
if cb_ring54.ItemIndex = 5 then widerstand := floattostr((strtofloat(wert)*1000));
if cb_ring54.ItemIndex = 6 then widerstand := floattostr((strtofloat(wert)*10000));
if cb_ring54.ItemIndex = 7 then widerstand := floattostr((strtofloat(wert)*100000));
if cb_ring54.ItemIndex = 8 then widerstand := floattostr((strtofloat(wert)*1000000));
if cb_ring54.ItemIndex = 9 then widerstand := floattostr((strtofloat(wert)*10000000));
end;
begin
if StrTofloat(widerstand)>=1000000 then begin
pnl_result.caption := (floattostr((strtofloat(widerstand)/
1000000))+' MOhm');
pnl_worstcasemin.caption := '?';
pnl_worstcasemax.caption := '?';
end;
if StrTofloat(widerstand)>=1000 then begin
if StrTofloat(widerstand)<1000000 then begin
pnl_result.caption := (floattostr((strtofloat(widerstand)/
1000))+' KOhm');
pnl_worstcasemin.caption := '?';
pnl_worstcasemax.caption := '?';
end;
end;
if StrTofloat(widerstand)<1000 then begin
pnl_result.caption := (floattostr((strtofloat(widerstand)/ ++++++das klappt
1))+' Ohm');
pnl_worstcasemin.caption := (floattostr((strtofloat(widerstand)/ ++++++und hier das problem
1+(tolerance))+' Ohm'));
pnl_worstcasemax.caption := (floattostr((strtofloat(widerstand)/ ++++++und hier das problem
1+(tolerance))+' Ohm'));
end;
tolerance := floattostr( (strtofloat(widerstand)/100)*(prozent));
if rb_5rings.Checked then begin

if cb_ring55.ItemIndex = 0 then begin ++++++wollte ich umstellen (case) tut dann aber auch dumm
pnl_Tolerance.Caption:= '5%';
prozent:=(5);
end;
if cb_ring55.ItemIndex = 1 then begin
pnl_Tolerance.Caption:= '1%';
prozent:=(1);
end;
if cb_ring55.ItemIndex = 2 then begin
pnl_Tolerance.Caption:= '2%';
prozent:=(2);
end;
if cb_ring55.ItemIndex = 3 then begin
pnl_Tolerance.Caption:= '0,5%';
prozent:=(0.5);
end;
if cb_ring55.ItemIndex = 4 then begin
pnl_Tolerance.Caption:= '0,25%';
prozent:=(0.25);
end;
if cb_ring55.ItemIndex = 5 then begin
pnl_Tolerance.Caption:= '0,1%';
prozent:=(0.1);
end;
end;

if rb_4rings.Checked then begin

if cb_ring4.ItemIndex = 0 then begin
pnl_Tolerance.Caption:= '10%';
prozent:=(10);
end;
if cb_ring4.ItemIndex = 1 then begin
pnl_Tolerance.Caption:= '5%';
prozent:=(5);
end;
if cb_ring4.ItemIndex = 2 then begin
pnl_Tolerance.Caption:= '1%';
prozent:=(1);
end;
if cb_ring4.ItemIndex = 3 then begin
pnl_Tolerance.Caption:= '2%';
prozent:=(2);
end;
if cb_ring4.ItemIndex = 4 then begin
pnl_Tolerance.Caption:= '0,5%';
prozent:=(0.5);
end;
if cb_ring4.ItemIndex = 5 then begin
pnl_Tolerance.Caption:= '0,25%';
prozent:=(0.25);
end;
if cb_ring4.ItemIndex = 6 then begin
pnl_Tolerance.Caption:= '0,1%';
prozent:=(0.1);
end;
end;

end;
end;



procedure TForm2.btn_execute_preresistClick(Sender: TObject);

begin +++hier bin ich noch nicht fertig mit umbauen
case trunc(resistor) of +++seit ich das so hab bleibt das panel beim ersten
 25000..33001:pnl_normresistor.Caption := '27 KOhm'; +++drücken des Buttons leer erst beim 2. betätigen
 16500..22001:pnl_normresistor.Caption := '22 KOhm'; +++erfolgt die ausgabe
 13500..16499:pnl_normresistor.Caption := '18 KOhm';
 12000..13499:pnl_normresistor.Caption := '15 KOhm';
10000..11999:pnl_normresistor.Caption := '12 KOhm';
8200..9999:pnl_normresistor.Caption := '10 KOhm';
6800..8199:pnl_normresistor.Caption := '8,2 KOhm';
5600..6799:pnl_normresistor.Caption := '6,8 KOhm';
4700..5599:pnl_normresistor.Caption := '5,6 KOhm';
3900..4699:pnl_normresistor.Caption := '4,7 KOhm';
3300..3899:pnl_normresistor.Caption := '3,9 KOhm';
2200..3299:pnl_normresistor.Caption := '3,3 KOhm';
end;
 {else
  case trunc(resistor*10) of
    1..12://ist (0.1)..(1.2)      alles mit kommastellen hier rein
  end;
}

 begin
if (Resistor)>2200 then begin
  if (Resistor)<3301 then
pnl_normresistor.Caption := (floattostr(2.2)+' KOhm')
end;
 end;
 begin
if (Resistor)>1625 then begin
  if (Resistor)<2201 then
pnl_normresistor.Caption := (floattostr(1.8)+' KOhm')
end;
 end;
 begin
if (Resistor)>1500 then begin
  if (Resistor)<1626 then
pnl_normresistor.Caption := (floattostr(1.5)+' KOhm')
end;
 end;


usw......
 end;
Marcel
  Mit Zitat antworten Zitat