![]() |
Re: Code optimieren
Zitat:
Delphi-Quellcode:
Resistor := floattostr(((strtofloat(edit_UV.text)- //widerstand
strtofloat(edit_UD.text))/strtofloat(edit_ID.text))*1000); +++++++ Nämlich hier if StrTofloat(Resistor)>=1000000 then begin //mohm pnl_calculated_resistor.caption := FloatToStr(Runden((strtofloat(resistor)/1000000),2)) +' MOhm'; end; if StrTofloat(Resistor)<1000000 then begin if StrTofloat(Resistor)>=1000 then begin //kohm pnl_calculated_resistor.caption := FloatToStr(Runden((strtofloat(resistor)/1000),2)) +' KOhm'; end; end; if StrTofloat(Resistor)<1000 then begin //ohm pnl_calculated_resistor.caption := FloatToStr(Runden((strtofloat(resistor)/1),2))+' Ohm'; end; aber sonst könnte das klappen und gefällt mir ganz gut |
Re: Code optimieren
aso...du berechnest den Widerstand...
na dann nehm als Typ extended. resistor:extended; und resistor:=(strtofloat(edit_UV.text)-strtofloat(edit_UD.text))/strtofloat(edit_ID.text)*1000; ich hoffe, die klammern passen noch... Gruß Frank |
Re: Code optimieren
och nö
Delphi-Quellcode:
begin
case resistor of **********ordinal type required 25000..33001:pnl_normresistor.Caption := '27 KOhm'; 16500..22001:pnl_normresistor.Caption := '22 KOhm'; |
Re: Code optimieren
jo, case geht nicht mit float
evtl. reicht ein
Delphi-Quellcode:
HTH Frank
case trunc(resistor) of
|
Re: Code optimieren
Ja Danke Reicht
Nächstes Problem :
Delphi-Quellcode:
erzeugt ein
if (Resistor)>=1000000 then begin //mohm *******Hab ich schon abgeändert
pnl_calculated_resistor.caption := FloatToStr(Runden(strtofloat(resistor)/1000000),2) +' MOhm'; //*****hier is bestimmt wieder ne klammer falsch end; if (Resistor)<1000000 then begin if (Resistor)>=1000 then begin //kohm pnl_calculated_resistor.caption := FloatToStr(Runden((strtofloat(resistor)/1000),2)) +' KOhm'; end; end; if (Resistor)<1000 then begin //ohm pnl_calculated_resistor.caption := FloatToStr(Runden((strtofloat(resistor)/1),2))+' Ohm'; end; Zitat:
|
Re: Code optimieren
du machst es schon wieder... (oder immer noch?)
strtofloat(resistor) mal davon abgesehen, dass du auch dort case verwenden kannst wie oben Frank |
Re: Code optimieren
Delphi-Quellcode:
So?
case trunc(resistor) of
1000000:pnl_calculated_resistor.caption := FloatToStr(Runden(strtofloat(resistor)/1000000),2) +' MOhm'; 999999..1000:pnl_calculated_resistor.caption := FloatToStr(Runden((strtofloat(resistor)/1000),2)) +' KOhm'; 9999:pnl_calculated_resistor.caption := FloatToStr(Runden((strtofloat(resistor)/1),2))+' Ohm'; end; Nerv ich eigendlich? |
Re: Code optimieren
Junge...liest du auch mal was wir schreiben?
Delphi-Quellcode:
(evtl. nach dem else kein ':')
case trunc(resistor) of
0..999:pnl_calculated_resistor.caption := FloatToStr(Runden(resistor,2))+' Ohm'; 1000..999999:pnl_calculated_resistor.caption := FloatToStr(Runden((resistor/1000),2)) +' KOhm'; else :pnl_calculated_resistor.caption := FloatToStr(Runden(resistor/1000000),2) +' MOhm'; end; das ständige umwandeln von/nach string... |
Re: Code optimieren
wegen Nichtbeachtung gelöscht
|
Re: Code optimieren
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:06 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