AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Probleme mit prozentrechnung

Ein Thema von Gehstock · begonnen am 3. Aug 2006 · letzter Beitrag vom 3. Aug 2006
 
Gehstock

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

Re: Probleme mit prozentrechnung

  Alt 3. Aug 2006, 19:25
Hab ja schon viel geschafft auch wenn der code mit sicherheit noch besser zu lösen ist


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

begin
if rb_4rings.Checked then begin
wert := floattostr(((cb_ring1.ItemIndex+1)*10) + cb_ring2.ItemIndex);
if cb_ring3.ItemIndex = 0 then wiederstand := floattostr((strtofloat(wert)/100));
if cb_ring3.ItemIndex = 1 then wiederstand := floattostr((strtofloat(wert)/10));
if cb_ring3.ItemIndex = 2 then wiederstand := floattostr((strtofloat(wert)*1));
if cb_ring3.ItemIndex = 3 then wiederstand := floattostr((strtofloat(wert)*10));
if cb_ring3.ItemIndex = 4 then wiederstand := floattostr((strtofloat(wert)*100));
if cb_ring3.ItemIndex = 5 then wiederstand := floattostr((strtofloat(wert)*1000));
if cb_ring3.ItemIndex = 6 then wiederstand := floattostr((strtofloat(wert)*10000));
if cb_ring3.ItemIndex = 7 then wiederstand := floattostr((strtofloat(wert)*100000));
if cb_ring3.ItemIndex = 8 then wiederstand := floattostr((strtofloat(wert)*1000000));
if cb_ring3.ItemIndex = 9 then wiederstand := 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 wiederstand := floattostr((strtofloat(wert)/100));
if cb_ring54.ItemIndex = 1 then wiederstand := floattostr((strtofloat(wert)/10));
if cb_ring54.ItemIndex = 2 then wiederstand := floattostr((strtofloat(wert)*1));
if cb_ring54.ItemIndex = 3 then wiederstand := floattostr((strtofloat(wert)*10));
if cb_ring54.ItemIndex = 4 then wiederstand := floattostr((strtofloat(wert)*100));
if cb_ring54.ItemIndex = 5 then wiederstand := floattostr((strtofloat(wert)*1000));
if cb_ring54.ItemIndex = 6 then wiederstand := floattostr((strtofloat(wert)*10000));
if cb_ring54.ItemIndex = 7 then wiederstand := floattostr((strtofloat(wert)*100000));
if cb_ring54.ItemIndex = 8 then wiederstand := floattostr((strtofloat(wert)*1000000));
if cb_ring54.ItemIndex = 9 then wiederstand := floattostr((strtofloat(wert)*10000000));
end;
begin
if StrTofloat(wiederstand)>999000 then begin
pnl_result.caption := (floattostr((strtofloat(wiederstand)/
1000000))+' MOhm');
pnl_worstcasemin.caption := (floattostr((strtofloat(wiederstand)/ //soll später die minimale toleranz werden
1))+' Ohm');
pnl_worstcasemax.caption := (floattostr((strtofloat(wiederstand)/ //soll später die maximale toleranz werden
1))+' Ohm');
end;
if StrTofloat(wiederstand)>999 then begin
if StrTofloat(wiederstand)<1000000 then begin
pnl_result.caption := (floattostr((strtofloat(wiederstand)/
1000))+' KOhm');
pnl_worstcasemin.caption := (floattostr((strtofloat(wiederstand)/ //soll später die minimale toleranz werden
1))+' Ohm');
pnl_worstcasemax.caption := (floattostr((strtofloat(wiederstand)/ //soll später die maximale toleranz werden
1))+' Ohm');
end;
end;
if StrTofloat(wiederstand)<1000 then begin
pnl_result.caption := (floattostr((strtofloat(wiederstand)/
1))+' Ohm');
pnl_worstcasemin.caption := (floattostr((strtofloat(wiederstand)/ //soll später die minimale toleranz werden
1))+' Ohm');
pnl_worstcasemax.caption := (floattostr((strtofloat(wiederstand)/ //soll später die maximale toleranz werden
1))+' Ohm');

end;
tolerance := strtofloat(pnl_result.caption)/100*(prozent); // hier die rechnung



if rb_4rings.Checked then begin
if cb_ring4.ItemIndex = 0 then begin
pnl_Tolerance.Caption:= '10%';
prozent:=floattostr(10); // muss bestmmt alles strtofloat
end;
if cb_ring4.ItemIndex = 1 then begin
pnl_Tolerance.Caption:= '5%';
prozent:=floattostr(5);
end;
if cb_ring4.ItemIndex = 2 then begin
pnl_Tolerance.Caption:= '1%';
prozent:=floattostr(1);
end;
if cb_ring4.ItemIndex = 3 then begin
pnl_Tolerance.Caption:= '2%';
prozent:=floattostr(2);
if cb_ring4.ItemIndex = 4 then begin
pnl_Tolerance.Caption:= '0,5%';
prozent:=floattostr(0.5);
end;
if cb_ring4.ItemIndex = 5 then begin
pnl_Tolerance.Caption:= '0,25%';
prozent:=floattostr(0.25);
end;
if cb_ring4.ItemIndex = 6 then begin
pnl_Tolerance.Caption:= '0,1%';
prozent:=floattostr(0.1);
end;
end;
if rb_5rings.Checked then begin
if cb_ring55.ItemIndex = 0 then begin
pnl_Tolerance.Caption:= '5%';
prozent:=floattostr(5);
end;
if cb_ring55.ItemIndex = 1 then begin
pnl_Tolerance.Caption:= '1%';
prozent:=floattostr(1);
end;
if cb_ring55.ItemIndex = 2 then begin
pnl_Tolerance.Caption:= '2%';
prozent:=floattostr(2);
end;
if cb_ring55.ItemIndex = 3 then begin
pnl_Tolerance.Caption:= '0,5%';
prozent:=floattostr(0.5);
end;
if cb_ring55.ItemIndex = 4 then begin
pnl_Tolerance.Caption:= '0,25%';
prozent:=floattostr(0.25);
end;
if cb_ring55.ItemIndex = 5 then begin
pnl_Tolerance.Caption:= '0,1%';
prozent:=floattostr(0.1);
end;
end;
end;
end;
end;
nich meckern es soll nur laufen bin ja noch am lernen
Marcel
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:58 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz