Autor Beitrag
Tabakbrummel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124

win 7
Turbo Delphi, VS 20010 Express
BeitragVerfasst: Mo 21.08.06 12:14 
Hallo

Mein Problem ist das die Werte nicht immer zweistellig, d.h. bis 9 fehlt die führende Null (die ich gerne hätte), aber leider kommt da die Fehlermeldung 'Format '%.2d' ungültig oder nicht kompatibel mit Argument'. Wie kann man das ändern?

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
procedure TForm4.Button7Click(Sender: TObject);
var
  Laenge : Extended;//Längengrad des Standorts, Bogenmaß
  Breite : Extended;//Breitengrad des Standorts, Bogenmaß
  h : Extended;//Korrekturfaktor für Lichtbeugung in Horizontnähe
  Deklination : Extended;
  Zeitdifferenz : Extended;
  Zeitgleichung : Extended;
  Woz_a : Extended;//wahre Ortszeit Sonnenaufgang
  Woz_u : Extended;//wahre Ortszeit Sonnenuntergang
  Moz_a : Extended;//mittlere Ortszeit Sonnenaufgang
  Moz_u : Extended;//mittlere Ortszeit Sonnenuntergang
  T : Extended;//Tageszahl, 1.Jan=1, 31.Dez=365 bzw. 366
  Aufgang_Std, Aufgang_Min : Extended;
  Untergang_Std, Untergang_Min : Extended;
begin
  LaengenGradberechnung;
  BreitenGradberechnung;
  Laenge:=StrToFloat(SpinEdit24.Text);
  Breite:=StrToFloat(SpinEdit25.Text);
  T:=Jahrestage;
  h:=-0.0145;//Konstante, 50 Bogenminuten
  Deklination:=0.40954*sin(0.0172*(T-79.349740));
  Zeitdifferenz:=12*arccos((sin(h)-sin(Breite)*sin(Deklination))/(cos(Breite)*cos(Deklination)))/Pi;
  Zeitgleichung:=-0.1752*sin(0.033430*T+0.5474)-0.1340*sin(0.018234*T-0.1939);
  Woz_a:=12-Zeitdifferenz-Zeitgleichung;
  Woz_u:=12+Zeitdifferenz-Zeitgleichung;
  Moz_a:=Woz_a-Zeitgleichung+((15-Laenge)*4/60);
  Moz_u:=Woz_u-Zeitgleichung+((15-Laenge)*4/60);
  Aufgang_Std:=Int(Moz_a);
  Aufgang_Min:=Int(60*(Moz_a-Int(Moz_a)));
  Panel12.Caption:=Format('%.2d',[FloatToStr(Aufgang_Std)])+':'+Format('%.2d',[FloatToStr(Aufgang_Min)]);
  Untergang_Std:=Int(Moz_u);
  Untergang_Min:=Int(60*(Moz_u-Int(Moz_u)));
  Panel13.Caption:=FloatToStr(Untergang_Std)+':'+Format('%.2d',[FloatToStr(Untergang_Min)]);
end;

_________________
MfG
Tabakbrummel
Kaoro-kun
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 35

Win XP
Delphi 7, Pascal
BeitragVerfasst: Mo 21.08.06 12:37 
Also, Ich weiss nicht, ob es dir etwas bringt, aber uns brachte man Stellenformatierung wie folgt bei:
Beispiel:
c:=a+b
label1.caption:=floattostrf(c,fffixed,<Stellen vor Komma>,<Stellen nach Komma>);
Ich hoffe Ich war eine Hilfe. :)
Regards,
Kao

_________________
Wissen ist Macht. Nichts Wissen macht nichts. Aber nichts zu Wissen, hat nichts mit Intelligenz zu tun. ;)
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 21.08.06 12:43 
Hallo,

Format('%.2d',[FloatToStr(Aufgang_Std)])

d steht für Dezimal, der Code übergibt aber mit FloatToStr einen String, also "nicht kompatibel mit Argument'"
Direkt den Integer übergeben :arrow:
ausblenden Delphi-Quelltext
1:
Format('%.2d',[Aufgang_Std])					

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Tabakbrummel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124

win 7
Turbo Delphi, VS 20010 Express
BeitragVerfasst: Mo 21.08.06 12:43 
Hallo

Ich meinte keine Kommastellen. Mein Problem ist, wenn ich auf den Buttob clicke kommt 9:9 raus aber ich will das 9:09 herraus kommt.

_________________
MfG
Tabakbrummel
Tabakbrummel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124

win 7
Turbo Delphi, VS 20010 Express
BeitragVerfasst: Mo 21.08.06 12:49 
Hallo Lannes

Jetzt kommt die Fehlermeldung Inkompatible Typen: 'Integer' und 'Extended'.

_________________
MfG
Tabakbrummel
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Mo 21.08.06 12:54 
Ähm, Hilfe lesen?

%d ist für Integer, für Float-Werte ist %f. Also ist für dich das richtige Format %.2f

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Tabakbrummel Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124

win 7
Turbo Delphi, VS 20010 Express
BeitragVerfasst: Mo 21.08.06 13:29 
Hallo

Ich habe es hin bekommen. Und vielen Dank für die Antworten.

_________________
MfG
Tabakbrummel