Results 1 to 5 of 5

Thread: Write command

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    Exclamation

    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)

  2. #2
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    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
    Dim

  3. #3
    Guest
    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

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    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)

  5. #5
    Addicted Member
    Join Date
    May 2000
    Posts
    240

    Wink 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
  •  



Click Here to Expand Forum to Full Width