Click to See Complete Forum and Search --> : Save My file
Chri
February 18th, 2000, 10:23 AM
I'm looking 4 a way to save my file in my program.
How ca&n I say : Create a new file, and write this and this at this place?
Or open this file and read this this and this?
thanx
February 18th, 2000, 10:33 AM
to write to a ".txt" file and make sure theres a folder called whatever:
open "c:\whatever\whatever.txt" for output as #1
write #1, text1
'if it says variable required, do this:
open "c:\whatever\whatever.txt" for output as #1
text1 = line
write #1, line
close #1
' make sure theres a textbox called text1 on your form
The Matrix
February 18th, 2000, 10:46 AM
i will talk to you in like 5 hours, and give you answer to reading the file
Kyle Burns
February 18th, 2000, 11:00 AM
I like to use the Scripting library for this:
Dim oFS as Scripting.FileSystemObject
Dim oStream as Scripting.TextStream
set oFS = new Scripting.FileSystemObject
'let's read a file here
set oStream = oFS.OpenTextFile("MYFILEPATHHERE")
While Not oStream.AtEndOfStream
MsgBox oStream.ReadLine()
Loop
'Now close the file
oStream.Close
'OK. We read a file. Now let's write one
set oStream = oFS.CreateTextFile("C:\WINDOWS\DESKTOP\Test.txt")
oStream.Write "This is a test"
oStream.Close
'Now release the objects
set oStream = nothing
set oFS = nothing
Chri
February 21st, 2000, 11:59 AM
Thanks 4 your answer pal.
I tried it and it worked for only one textbox.
But how can I save for more than one box?
(I have to write +-30 boxes)
Chri
Chri
February 21st, 2000, 12:01 PM
Thanx 4 your answer,...
Can you explain me how I can open a file and import text to +-30 different textboxes? (with diferent text)
Chri
Please reply at my E-MAIL (anoniempjes@hotmail.com)
Kyle Burns
February 21st, 2000, 02:05 PM
Don't hard code the file number. The correct way to get your file number (the as #) is to call FreeFile(). This will give you the next available file number.
You would need to repeat the code for each box. If you use an array of Text Boxes, you ca just loop through the array.
e.g.
'open your file here
Dim iFileNum as Integer
iFileNum = FreeFile()
Open "<<FilePathHere>>" for Output as iFileNum
for i = 0 to 29
write #iFileNum, txt(i).Text
next i
'Close Your File and clean up
Chri
February 25th, 2000, 11:56 AM
thanks pal,
I'l have to rename all textboxses, but it's worth it...
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.