|
-
Jul 17th, 2000, 12:42 PM
#1
Thread Starter
Hyperactive Member
Ok I know how to write to a file using append and output....however how about if I wanted to write to a certine line in a file. For example How would i write off to line 1 and on to line 2?
-RaY
VB .Net 2010 (Ultimate)
-
Jul 17th, 2000, 01:53 PM
#2
Fanatic Member
I'm most likely wrong...
but i think it's something like:
Code:
blah = 0
Open "hosts.txt" For Input As #1
Do Until EOF(1)
blah = blah + 1
If blah = 1 Then Line Input #1, somevar$: Text1 = Text1 & somevar$
If blah = 2 Then Line Input #1, somevar$: Text2 = Text2 & somevar$
If blah = 3 Then Line Input #1, somevar$: Text3 = Text3 & somevar$: blah = 0
So you would maily need the "Line Input #1, Text1"
Hope that helped,
D!m
-
Jul 17th, 2000, 02:10 PM
#3
You can write a blank line using vbNewLine. Although, that line will still be considered a variable.
Code:
Open "MyFile.txt" For Output As #1
Write #1, vbNewLine, "2nd Line"
Close #1
-
Jul 17th, 2000, 02:13 PM
#4
Thread Starter
Hyperactive Member
Thanks
Thanks a lot, I just did it the long way. There where six different things instead of putting them in 6 different lines i used 6 different text files since thats how I knew how to do it.
-RaY
VB .Net 2010 (Ultimate)
-
Jul 17th, 2000, 02:13 PM
#5
Addicted Member
Use the Append statement to add to a file..
This is how i did it to add lines to autoexec.bat file,but it works the same for .txt files.
Option Explicit
Dim Message As String, Message1 As String
Dim Message2 As String
Form_Load
Message = "What?"
Message1 = "Huh?"
Message2 = "Yeah"
Open "c:\windows\whatever.txt" For Append As #1
Print #1, Message
Close #1
Open "c:\windows\whatever.txt" For Append As #2
Print #2, Message1
Close#2
Open "c:\windows\whatever.txt" For Append As #3
Print #3, Message2
Close #3
End Sub
I am sure there is a better way to do this ,but at the moment i dont know how to do it any other way...
Later
NewBEE Vbeer6.0()
"Gopher this Gopher that"
End Sub
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
|