Results 1 to 6 of 6

Thread: Really stupid question... RESOLVED, although still available due to popular demand

  1. #1

    Thread Starter
    Fanatic Member VisionIT's Avatar
    Join Date
    Nov 2002
    Location
    Workin'...
    Posts
    718

    Really stupid question... RESOLVED, although still available due to popular demand

    Right...

    If I want to enter a line of text into a file called test.txt... how would I do it?

    What would happen if there's already text in the file... i need it to add the line, and NOT overwrite the file completely.

    So the user enters a line which says...

    "Stupid question"

    The test.txt file would read...

    Stupid question

    The next user enter's...

    "Need an answer"

    The test.txt would then read...

    Stupid question
    Need an answer

    Any ideas please... my mind's gone totally dead this evening. Anyone want to sell their's ?

    Regards,

    Paul.
    Last edited by VisionIT; Feb 7th, 2003 at 05:56 PM.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Instead of opening the file for Output, open it for Append.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Stupid.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  4. #4
    Hyperactive Member TupacShakur's Avatar
    Join Date
    Mar 2002
    Location
    Da Land Of Da Heartless...
    Posts
    493

    Lightbulb Append

    VB Code:
    1. 'Sub to append to a file passed as argument
    2. Private Sub AppendFile(FileName As String, Text as String)
    3. Dim X as Integer
    4. X = FreeFile
    5. Open FileName For Append As #X
    6. Print #X, Text
    7. Close #X
    8. End Sub
    is one way to do it.
    HTH

    Regards,
    Me
    "And Now I'm Lika Major Threat, Cause I Remind U Of The Things U Were Made To Forget!" - (2PAC)

    "Now They Label Me a Lunatic, Couldn't Care Less, Death or Success is What I Quest, Cause I'm Fearless!" - (2PAC)

    " There's a light at the end of every tunnel, just pray it's not a train!! "



    I am 100% addicted to Tupac. What about you?
    I am 24% addicted to Counterstrike. What about you?
    The #1 Tupac Fans Web Site | The Official Tupac Web Site

  5. #5

    Thread Starter
    Fanatic Member VisionIT's Avatar
    Join Date
    Nov 2002
    Location
    Workin'...
    Posts
    718
    Cheers buddy... although i'm not quite sure about the stupid part

    I just can't think straight 2nite.... infact, I struggle quite often anyway

    Thanks again... and i'll delete this post to save me from a few jokes!

    Regards,

    Paul.

  6. #6
    Fanatic Member Geespot's Avatar
    Join Date
    Oct 2001
    Location
    Birmingham, UK
    Posts
    577
    No don't delete the thread, infact its a very interesting question to a VB starter

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