Einzelnen Beitrag anzeigen

Gehstock

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

Re: Probleme mit prozentrechnung

  Alt 3. Aug 2006, 20:59
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)-tolerance)/
1000000))+' MOhm');
pnl_worstcasemax.caption := (floattostr(((strtofloat(wiederstand)+tolerance)/
1000000))+' MOhm');   }

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)-tolerance)/
1000))+' KOhm');
pnl_worstcasemax.caption := (floattostr(((strtofloat(wiederstand)+tolerance)/
1000))+' KOhm');     }

end;
end;
if StrTofloat(wiederstand)<1000 then begin
pnl_result.caption := (floattostr((strtofloat(wiederstand)/
1))+' Ohm');
{pnl_worstcasemin.caption := (floattostr(((strtofloat(wiederstand)-tolerance)/
1))+' Ohm');
pnl_worstcasemax.caption := (floattostr(((strtofloat(wiederstand)+tolerance)/
1))+' Ohm');        }

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



if rb_4rings.Checked then begin
if cb_ring4.ItemIndex = 0 then begin
pnl_Tolerance.Caption:= '10%';
prozent:=floattostr(10);
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;


kannst du mir bitte trotzdem helfen
Marcel
  Mit Zitat antworten Zitat