Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Di 09.02.10 20:36 
Hi, Delpher,

wie kann ich formatiert in eine Listbox schreiben?

Mein kläglicher Versuch:

ausblenden Delphi-Quelltext
1:
listbox1.items.add(format('%4s', [n]), ' ' , nomen);					


Gibt natürlich eine Fehlermeldung,
Det

---Moderiert von user profile iconNarses: Beiträge zusammengefasst---

Au weiah,
tatsächlich mit +
Detlef :oops: :oops:

---Moderiert von user profile iconNarses: Beiträge zusammengefasst---

Nein doch nicht, Error zur Laufzeit - Mist, zu früh gefreut

_________________
ut vires desint, tamen est laudanda voluntas
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Di 09.02.10 20:54 
user profile iconD. Annies hat folgendes geschrieben Zum zitierten Posting springen:
Error zur Laufzeit

Gewöhnst du dir irgendwann noch an, die Fehlermeldung mitzuliefern?

_________________
PROGRAMMER: A device for converting coffee into software.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 10.02.10 05:34 
Hi, Xentar,

das mache ich doch sonst auch, diesmal dachte ich, es ist (eigentlich) so leicht zu lösen, dass ich darauf verzichten kann bei einer Zeile Code.

Tschuldigung, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mi 10.02.10 08:25 
Tut mir Leid, hab wohl etwas überreagiert.

Also, noch mal eben für die Allgemeinheit:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var  nomen: string;
    n: integer;
begin
  n := 12;
  nomen := 'huddel';
  listbox1.items.add(format('%4s', [n]) + ' ' + nomen);

Kommt der Fehler "Format %4s ungültig oder nicht kompatibel mit Argument".
Grund: n ist ein Integer, du sagt der Format Funktion aber, dass da ein String kommt.

Lösung + Verbesserung:
ausblenden Delphi-Quelltext
1:
  listbox1.items.add(format('%4d %s', [n, nomen]));					


Und wenn du führende Nullen möchtest:
ausblenden Delphi-Quelltext
1:
  listbox1.items.add(format('%.4d %s', [n, nomen]));					

_________________
PROGRAMMER: A device for converting coffee into software.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 10.02.10 08:40 
Hi, Xentar,
danke erstmal!
Ja, der Grund war die falsche Formatierung, also %d statt %s
Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas