|
-
Sep 10th, 2000, 01:40 AM
#1
Thread Starter
Addicted Member
how can I opena file,
Code:
Open "c:\windows\desktop\test1.txt" For Input As #1
count the number of line
and add a new line in the file ...
ex.:
before:
Line1
line2
After:
Line1
Line2
Line3
cause now, my code do that :
Line1Line2Line3
-
Sep 10th, 2000, 01:51 AM
#2
Here's how to read a text file:
Code:
Open "MyFile" For Input As #1
Text1.Text = Input$(LOF(1), 1)
Close #1
And to save it:
Code:
Open "MyFile" For Output As #1
Print #1, Text1.Text
Close #1
[Edited by Matthew Gates on 09-10-2000 at 02:53 AM]
-
Sep 10th, 2000, 01:54 AM
#3
Thread Starter
Addicted Member
Ok..
there is no way to UPDATE the file..
so..
it,s because it will be a log fil of all a year..
in all a scool..
-
Sep 10th, 2000, 01:59 AM
#4
Well, if you want to add to the end of it:
Code:
Open "MyFile" For Append As #1
Print #1, Text1.text
Close #1
-
Sep 10th, 2000, 06:57 AM
#5
_______
<?>
Working with files you should use the Freefile function:
FreeFile supplies a file number that is not already in use.
Dim intNum as integer
intNum = Freefile
Open "yourpath/yourfile.ext" for Append as Intnum
You can open tons of files this way and never have to keep track of the file numbers used. #1,#2,#3
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 10th, 2000, 08:35 AM
#6
Frenzied Member
Code:
Dim fn As FreeFile, i as Long
Open FILE for Input As #fn
Do While Not EOF(fn)
Line Input #fn, MyStr
i = i + 1
Loop
Close
MsgBox "Your file contains " & i & " lines!"
have fun!
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Sep 10th, 2000, 10:02 AM
#7
Thread Starter
Addicted Member
Did ...
Code:
Open "MyFile" For Append As #1
Print #1, Text1.text
Close #1
... Will add a line before put a new data :
BEFORE1
BEFORE2
AFTER
Or:
BEFORE1
BEFORE2AFTER
-
Sep 10th, 2000, 10:13 AM
#8
_______
<?>
'this is the content of myfile.txt before
Before
Before2
Before3
[code]
Option Explicit
Private Sub Form_Load()
Text1 = "This is after I append"
Dim myFile As String
Dim intNum As Integer
myFile = "C:\my documents\myfile.txt"
intNum = FreeFile
Open myFile For Append As intNum
Print #1, Text1.Text
Close intNum
End Sub
[code]
'this is it after running the above
Before
Before2
Before3
This is after I append
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 10th, 2000, 10:19 AM
#9
Thread Starter
Addicted Member
Ok..
thak's it's exactly what I need..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|