Forum > General
Reading and writting a file into a list box not working so well.
(1/1)
captian jaster:
--- Code: ---procedure TForm1.OpenBtnClick(Sender: TObject);
begin
AssignFile(SaveFile,'Records.txt');
IF NOT(Fileexists('Records.txt'))Then ShowMessage('Records Not Found!')Else
begin
Reset(SaveFile);
Repeat
Readln(SaveFile,ReadStr);
Form1.Box.Items.Add(ReadStr);
until(EoF(SaveFile));
end;
end;
--- End code ---
Normally yeah this should work and it does sometimes...
But in my program i can clear the list box. so when i click to clear it then i press the open button(its what this does) it raises an error and i dont know why. let me know if i have to post the whole code
thnx
captian jaster:
Never mind, i fixed it
Troodon:
don't forget to close the file.
captian jaster:
yeah thats what i forgot to do :)
theo:
This code does the same in one line:
--- Code: --- ListBox1.Items.LoadFromFile('Records.txt');
--- End code ---
Navigation
[0] Message Index