![]() |
Re: zahl in Uhrzeit darstellen
also ich hatte genau deine function vor die procedure gesetzt.
nur find ich da irgendwie keinen fehler, nochma alles:
Delphi-Quellcode:
function SecToStr (sec: Int64): string;
var DT : TDateTime; begin DT := sec / (60 * 60 * 24); Result := IntToStr(Trunc(DT)) + ' Tage'; end; procedure TForm1.Button1Click(Sender: TObject); var prodiri, prodhol, prodo2, wk, hol, o2, iri, bbt: real; iri2, hol2, o22, iri3, hol3, o23: real; iritag, holtag, o2tag: real; iristd, holstd, o2std: real; iriv, irib, holv, holb, o2v, o2b: real; irig: real; begin prodiri := strtofloat(edit1.Text); prodhol := strtofloat(edit4.text); prodo2 := strtofloat(edit5.text); bbt := strtofloat(edit2.text); wk := strtofloat(edit3.text); iri := (10 * (1 + (Power(prodiri,1.9)))); hol := (10 * (1 + (Power(prodhol,1.8)))); o2 := (10 * (Power(prodo2,2))); iri2 := iri * (Power(1 + 5/100, bbt)); hol2 := hol * (Power(1 + 5/100, bbt)); o22 := o2 * (Power(1 + 5/100,wk) * (20/70)); label1.Caption := floattostr(iri2); label2.Caption := floattostr(hol2); label4.Caption := floattostr(o22); iritag := iri2 * 24; holtag := hol2 * 24; o2tag := o22 * 24; label10.caption := floattostr(iritag); label11.caption := floattostr(holtag); label12.caption := floattostr(o2tag); iristd := strtofloat(edit6.text) * iri2; holstd := strtofloat(edit6.text) * hol2; o2std := strtofloat(edit6.text) * o22; label19.Caption := floattostr(iristd); label20.Caption := floattostr(holstd); label21.Caption := floattostr(o2std); iriv := strtofloat(edit7.text); irib := strtofloat(edit8.text); holv := strtofloat(edit9.text); holb := strtofloat(edit10.text); o2v := strtofloat(edit11.text); o2b := strtofloat(edit12.text); irig := floattosec((irib - iriv) / iri2); label51.caption := sectostr(irig); end; |
Re: zahl in Uhrzeit darstellen
Zitat:
|
Re: zahl in Uhrzeit darstellen
ok dann weiß ich schonma wie das mit dem aufrufen der function geht aber jetzt hab ich das entfernt nun hab ich in dieser zeile:
Delphi-Quellcode:
den fehler:
label51.caption := SectoStr(irig);
[Fehler] ets_res_prod2.pas(174): E2010 Inkompatible Typen: 'Int64' und 'Real' Liegt es damit zu sammen das ich irig als real deklariert hab und der rückgabewert in int64 ist? |
Re: zahl in Uhrzeit darstellen
Du brauchst jetzt die Funktionen zum Konvertieren:
FloatToStr StrToFloat IntToStr StrToInt FloatToStr StrToFloat usw. Float = Real Int = Integer steht alles in der Hilfe. |
Re: zahl in Uhrzeit darstellen
nur das doofe ist ja das es keine ganzzahligen zahlen sind und integer nur ganzzahlige beeinhaltet.
Im mom hab ich keine Ahnung wie ich das machn könnte |
Re: zahl in Uhrzeit darstellen
Zitat:
Delphi-Quellcode:
mfg
function SecToStr (sec: Int64): string;
function SecToStr (sec: Double): string; |
Re: zahl in Uhrzeit darstellen
Zitat:
|
Re: zahl in Uhrzeit darstellen
hmmm :shock: :shock: :shock: :shock: :shock: :shock:
blicke da nicht durch. Also der rückgabewert der function ist als string deklariert richtig? Dann muss ich doch irig auch als string deklarieren seh ich das richtig? Hab jetzt einfach ma irig als string deklaerier habe aber dann in der letzten zeile noch einen Fehler: "[Fehler] ets_res_prod2.pas(174): E2010 Inkompatible Typen: 'Int64' und 'string'" Demnach wäre der rückgabewert int64 jetzt meine frage wie mach ich des denn richtig? |
Re: zahl in Uhrzeit darstellen
Zeig man die QuellCodeZeile zu dieser Fehlermeldung.
PS: der Fehler könnte auch gut bei einem anderem Parameter liegen ... also wenn das mit dem String jetzt stimmt ;) |
Re: zahl in Uhrzeit darstellen
Unit: System
Description: The Trunc function truncates a real-type value to an integer-type value. X is a real-type expression. Trunc returns an Int64 value that is the value of X rounded toward zero. If the truncated value of X is not within the Int64 range, an EInvalidOp exception is raised.
Delphi-Quellcode:
...
label51.caption := sectostr(Trunc(irig)); ... |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:46 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 by Thomas Breitkreuz