![]() |
Wie kann ich das rechnen
soll so rechnen (cb_ring1.ItemIndex*10)+cb_ring2.ItemIndex
Delphi-Quellcode:
cb_ring1 sind also die 10ér stellen
daten := floattostr(((strtofloat(cb_ring1.ItemIndex)*10)+
strtofloat(cb_ring2.ItemIndex))); cb_ring2 sind die 1ér klappt aber nicht |
Re: Wie kann ich das rechnen
und was klappt nicht? gibt es nen fehler?
|
Re: Wie kann ich das rechnen
.ItemIndex ist normalerweise in Integer ;-)
|
Re: Wie kann ich das rechnen
Ich weiß zwar nicht was cb_ring1 und cb_ring2 ist, aber ItemIndex sollte im Normalfall ein Integer sein.
Also warum StrToFloat ???
Delphi-Quellcode:
//Edit:
daten := IntToStr((cb_ring1.ItemIndex*10) + cb_ring2.ItemIndex);
Dann recht auch IntToStr! |
Re: Wie kann ich das rechnen
Hallo!
Kann es sein, daß Du hier zwei Comboboxen mit den Ziffern [0..9] gefüllt hast und nun den Wert ermitteln willst, den der Benutzer eingestellt hat? Dann muss das so sein:
Delphi-Quellcode:
hope it helps
daten := (StrToInt (cb_ring1.Items[cb_ring1.ItemIndex])) * 10
+ (StrToInt (cb_ring2.Items[cb_ring2.ItemIndex])); onlinekater |
Re: Wie kann ich das rechnen
Delphi-Quellcode:
klappt einwandfre
daten := IntToStr((cb_ring1.ItemIndex*10) + cb_ring2.ItemIndex);
nächstes problem prozentrechnung
Delphi-Quellcode:
if StrTofloat(wiederstand)<1000 then begin
pnl_result.caption := (floattostr((strtofloat(wiederstand)/ ///wiederstand ist ne variable 1))+' Ohm');// der genaue wert pnl_worstcasemin.caption := (floattostr((strtofloat(wiederstand)/ ???????))+' Ohm');// der minimale wert pnl_worstcasemax.caption := (floattostr((strtofloat(wiederstand)/ ???????))+' Ohm');// der maximale wert end; if rb_4rings.Checked then begin if cb_ring4.ItemIndex = 0 then pnl_Tolerance.Caption:= '10%'; // und hier sind die toleranzen if cb_ring4.ItemIndex = 1 then pnl_Tolerance.Caption:= '5%' ; if cb_ring4.ItemIndex = 2 then pnl_Tolerance.Caption:= '1%' ; if cb_ring4.ItemIndex = 3 then pnl_Tolerance.Caption:= '2%' ; if cb_ring4.ItemIndex = 4 then pnl_Tolerance.Caption:= '0,5%'; if cb_ring4.ItemIndex = 5 then pnl_Tolerance.Caption:= '0,25%'; if cb_ring4.ItemIndex = 6 then pnl_Tolerance.Caption:= '0,1%' ; end; if rb_5rings.Checked then begin if cb_ring55.ItemIndex = 0 then pnl_Tolerance.Caption:= '5%'; if cb_ring55.ItemIndex = 1 then pnl_Tolerance.Caption:= '1%' ; if cb_ring55.ItemIndex = 2 then pnl_Tolerance.Caption:= '2%' ; if cb_ring55.ItemIndex = 3 then pnl_Tolerance.Caption:= '0,5%' ; if cb_ring55.ItemIndex = 4 then pnl_Tolerance.Caption:= '0,25%'; if cb_ring55.ItemIndex = 5 then pnl_Tolerance.Caption:= '0,1%'; end; end; |
Re: Wie kann ich das rechnen
Ich würde den Widerstand in einer (Extended)-variablen zwischenspeichern und dann mit dieser Weiterrechnen.
Die erste Zeile kannst du vereinfachen, indem du den String nimmst und ' Ohm' hinzufügst den eine Zahl durch ein ergibt ja die Zahl ;-) Wie berechnen sich die anderen Werte ( minimal + maximal)? und was daß mit Prozentrechnung zu tun? |
Re: Wie kann ich das rechnen
ich würde dir als erstes emphelen dir mal den styleguide auf
![]()
Delphi-Quellcode:
sieht doch schon mal besser aus, oder?var x: extended; begin if rb_4rings.Checked then begin x := cb_ring4.ItemIndex case x of 0: pnl_Tolerance.Caption:= '10%'; // und hier sind die toleranzen 1: pnl_Tolerance.Caption:= '5%' ; 2: pnl_Tolerance.Caption:= '1%' ; 3: pnl_Tolerance.Caption:= '2%' ; 4: pnl_Tolerance.Caption:= '0,5%'; 5: pnl_Tolerance.Caption:= '0,25%'; 6: pnl_Tolerance.Caption:= '0,1%' ; end; end; end; |
Re: Wie kann ich das rechnen
Delphi-Quellcode:
kann mir das jemand so umstellen das es klappt
tolerance := floattostr((strtofloat((pnl_result.caption)/100)*prozent));
|
Re: Wie kann ich das rechnen
Hi!
Könntest du bitte deinem Thread noch einen aussagekräftigen Titel geben? Darunter kann man sich nur wenig vorstellen! Ciao, Frederic |
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:20 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