PDA

Click to See Complete Forum and Search --> : text file


Mohammed
Dec 30th, 1999, 02:52 AM
Any time I tried to creat a text file, than open it for any reason, I get different error message. Please, can I get a example program to:
- How creat a text file?
- How to add a record to this file, after loadinf the form, or program?
- How can display the contents of the file in treeview or listbox?
Thank you,
NOTE: I just start learning using VB, so I do appreciate any help.
Mohammed.

Dec 30th, 1999, 04:07 AM
to start a file:
(dont declare FreeFile)

MyData = "hello Mohammed"
MyFile = Freefile
Open "C:\ThisFile.txt" for output as #MyFile
print #MyFile, MyData
print #myfile, "!!!"
close #myfile


try this code and then use notepad to open the file (C:\ThisFile.txt) then you'll see what ive done.

to add to the end of this original file swap the word Output for "Append" in the above code.


to put all the data from the file into a listbox:

MyfileX = Freefile
open "C:\ThisFile.txt" for input as #myfilex
do while not EOF(MyFilex)

line input #myfilex, LineString
list1.additem LineString

loop

close #myfilex

mail me:
wossnamex@talk21.com

[This message has been edited by wossname (edited 12-30-1999).]

[This message has been edited by wossname (edited 12-30-1999).]