Results 1 to 10 of 10

Thread: Ahh creating files

  1. #1

    Thread Starter
    Lively Member n00b1337's Avatar
    Join Date
    Sep 2003
    Location
    Berlin Connecticut
    Posts
    67

    Unhappy Ahh creating files

    OK hello im only 17 and im learning Vb on my own, i have a project onwhich i have to create. but of course theres an issue.
    I have the coding

    dim studentname as string
    open "C:\test1.text" for output as #1
    studentname= text1.text
    print #1, studentname
    close #1
    if i type my name (Jordan) into the text1.text it creates the file like its saposed to, BUT if i type John into it , it erases Jordan and only puts John in there! I need to know how to add multiple things to the file without erasing the existing information.
    PLz help me
    [VBcode]
    SubLife_Load()
    If Age>25
    Unload me
    end if
    sub end

    [/vbcode]

  2. #2
    Fanatic Member JPicasso's Avatar
    Join Date
    Aug 2001
    Location
    Kalamazoo, MI
    Posts
    843

    Re: Ahh creating files

    Originally posted by n00b1337
    OK hello im only 17 and im learning Vb on my own, i have a project onwhich i have to create. but of course theres an issue.
    I have the coding

    dim studentname as string
    open "C:\test1.text" for append as #1
    studentname= text1.text
    print #1, studentname
    close #1
    if i type my name (Jordan) into the text1.text it creates the file like its saposed to, BUT if i type John into it , it erases Jordan and only puts John in there! I need to know how to add multiple things to the file without erasing the existing information.
    PLz help me
    Merry Christmas

  3. #3

    Thread Starter
    Lively Member n00b1337's Avatar
    Join Date
    Sep 2003
    Location
    Berlin Connecticut
    Posts
    67
    still not working
    [VBcode]
    SubLife_Load()
    If Age>25
    Unload me
    end if
    sub end

    [/vbcode]

  4. #4
    Fanatic Member JPicasso's Avatar
    Join Date
    Aug 2001
    Location
    Kalamazoo, MI
    Posts
    843

    Re: Ahh creating files

    dim studentname as string
    open "C:\test1.txt" for append as #1
    studentname= text1.text
    print #1, studentname
    close #1


    it works.
    Merry Christmas

  5. #5

    Thread Starter
    Lively Member n00b1337's Avatar
    Join Date
    Sep 2003
    Location
    Berlin Connecticut
    Posts
    67
    i put in what u wrote and its still not working , lemme explain what i want it to do alittle better... i want it to write the names to that file now that it is created, but whenever it writes to it , it erases what was in the folder in the first place. (this is a new question) how would i get the program to check and see if the username is in that file??
    [VBcode]
    SubLife_Load()
    If Age>25
    Unload me
    end if
    sub end

    [/vbcode]

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    how would i get the program to check and see if the username is in that file??
    read the file into variable
    search the variable for the name using instr
    -= a peet post =-

  7. #7
    Fanatic Member JPicasso's Avatar
    Join Date
    Aug 2001
    Location
    Kalamazoo, MI
    Posts
    843
    I don't know what you want, but the code does what you asked for.
    If you run the supplied code, it will add new entries to the "C:\Test1.text" or "C:\test1.txt" file.

    You attempted to explain, but you are talking appending to a file, and then you switch to a folder.

    If Peet hasn't answered your question, please try and explain again, cause I don't understand.
    Merry Christmas

  8. #8

    Thread Starter
    Lively Member n00b1337's Avatar
    Join Date
    Sep 2003
    Location
    Berlin Connecticut
    Posts
    67
    ok im sorry for not being descriptive enough, im still n00b. but i tried the append and it didnt do anything, i checked C:\Test.txt and it didnt change it, it still only says jordan, im sorry if im not explaining enough im trying i think its messing up becuase im telling it to create again, so it might just be over writing the original.
    [VBcode]
    SubLife_Load()
    If Age>25
    Unload me
    end if
    sub end

    [/vbcode]

  9. #9
    Fanatic Member joltremari's Avatar
    Join Date
    Sep 2000
    Location
    Mississippi
    Posts
    674
    ok im sorry for not being descriptive enough, im still n00b. but i tried the append and it didnt do anything, i checked C:\Test.txt and it didnt change it, it still only says jordan, im sorry if im not explaining enough im trying i think its messing up becuase im telling it to create again, so it might just be over writing the original.
    Your code in your first post says C:\Test1.text
    Your code in the above quote says C:\Test.txt

    Check that your looking at the same file your writing to. JPicasso is right if you used append exactly as he showed then it worked.

    What event are you using to run this code?( command button click etc...)

    Post your entire code there may be a problem somewhere else.

    JO
    "I have not failed. I've just found 10,000 ways that won't work."
    'Thomas Edison'

    "If we knew what it was we were doing it wouldn't be called research, would it?"
    'Albert Einstein'

    VB6

  10. #10
    Fanatic Member JPicasso's Avatar
    Join Date
    Aug 2001
    Location
    Kalamazoo, MI
    Posts
    843
    Attached is a form,

    with only a text box and a button.

    1. delete test1.txt from your C drive.
    2. run the program and input several names and hit the button a couple of times.
    3. check the file.
    Attached Files Attached Files
    Merry Christmas

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