Autor Beitrag
Eihwaz
Hält's aus hier
Beiträge: 9

Win 2k

BeitragVerfasst: Do 10.02.05 14:46 
so... tag erstmal :wink: erster beitrag hier und schon ne frage... na gut, sonst wäre ich nicht hier ^_^
also dann mal los...

problem: ich will eine txt-datei in eine listbox laden. die entsprechende .txt-datei krieg ich auch ohne probleme erzeugt. nun ist mir aber grade überhaupt nicht klar, wie ich es schaffe, dass diese .txt-datei bei jedem start automatisch (mit einem timer?) in meine listbox geladen wird.
die txt sieht folgendermaßen aus:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
xyz
zyx
yzx
abc
xyz
123456

die entsprechende listbox sollte auch so aussehen... eben mit den zeilenumbrüchen.
ich denke mal, dass ich hier mit dem LoadFromFile-befehl arbeiten muss... richtig soweit?
wenn ja, wie müsste der entsprechende befehl genau aussehen?
ich bin nur auf
ausblenden Delphi-Quelltext
1:
2:
3:
4:
begin
<...>
listbox1 := ('adressen.txt')
end;

gekommen... natürlich klappt es nicht... :/
ich bin mir sicher, dass ihr hier hier weiterhelfen könnt... ^_^
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Do 10.02.05 14:48 
wie wärs mit listbox1.loadfromfile('C:\test.txt');
Eihwaz Threadstarter
Hält's aus hier
Beiträge: 9

Win 2k

BeitragVerfasst: Do 10.02.05 15:12 
ne, geht auch nicht... "undeclared identifier: 'loadfromfile' "
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Do 10.02.05 15:13 
listbox1.items.loadfromfile


Zuletzt bearbeitet von Karlson am Do 10.02.05 15:18, insgesamt 1-mal bearbeitet
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Do 10.02.05 15:14 
dann mach eine neue TStringlist, die kannst du mit loadfromfile laden. und anschliessend mit listbox1.assign(myStringList) zuweisen.
falls das ned geht musst du die stringliste mit einer for schleife von 0 to count - 1 durchlaufen lassen.
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Do 10.02.05 15:17 
Wo liegt das Problem?

ListBox1.items ist vom Typ TStrings. Die kann man doch wohl mit LoadFromFile auslesen...

ich meine natürlich items, nicht lines, tippfehler.

@retnyg: Du vergisst jedesmal die ITEMS!!! ;)
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Do 10.02.05 15:22 
ach herrje :twisted:

die sollte man ja nicht vergessen ;)
Eihwaz Threadstarter
Hält's aus hier
Beiträge: 9

Win 2k

BeitragVerfasst: Do 10.02.05 15:31 
ah danke, so klappt es ;D

was so ein kleines wort wie items doch auslösen kann... *g*
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Do 10.02.05 15:34 
wie kommtst du eigentlich auf die idee mit dem timer ?
mach das ins Form1.show rein und dann wird das bei jedem start geladen,
bzw immer dann wenn die form1 angezeigt wird
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Do 10.02.05 15:40 
was fürn timer ???? fearofthedark, du solltest etwas genauer lesen bevor du drauflospostest.
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Do 10.02.05 15:42 
Zitat:

dass diese .txt-datei bei jedem start automatisch (mit einem timer?) in meine listbox geladen wird


daher kommt er drauf ;>
Eihwaz Threadstarter
Hält's aus hier
Beiträge: 9

Win 2k

BeitragVerfasst: Do 10.02.05 15:43 
das mit dem timer war nur ein einfall... da ich auch nen timer hab, um zu testen, ob eine entsprechende datei vorhanden ist. allerdings ist das ja nicht wichtig für das (gelöste) problem.
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Do 10.02.05 15:44 
:D schade uall, dass du mir zuvor gekommen bist :wink:

tja erstmal genau lesen :P :!: 8)
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Do 10.02.05 15:46 
Hey aber mal ehrlich, wer liest sich solche Opening Posts denn wirklich durch, wenn die Frage schon im Titel steht :lol:
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Do 10.02.05 15:46 
ich wasche meine hände in unschuld *flöt*