Results 1 to 6 of 6

Thread: textfile

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2003
    Location
    Sydney
    Posts
    107

    textfile

    hi did the following code so when it saves everything in the label and text box to a text.file

    when i add new data in the text boxes and save it, overrides the old text file.

    what i need is everytime i add new data to text boxes and save it creates a new text file no overide the previous one created

    Private Sub mnuFileSave_Click()
    Open "C:\Program Files\Project\Project .txt" For Output As #1
    Print #1, "Label1. " & label2 & " saved at " & Now & "."
    Print #1, "label3 " & text1 & " " & text2 & " " & text3 & " " & text4

    Close #1
    End Sub
    Thnx In Advance

  2. #2
    Fanatic Member laserman's Avatar
    Join Date
    Jan 2002
    Location
    Wales U.K
    Posts
    775
    Where it sais for output change to for append

    ok

    Cheers

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2003
    Location
    Sydney
    Posts
    107
    tried that but doesn't create a new one
    Thnx In Advance

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2003
    Location
    Sydney
    Posts
    107
    Ok me other problem is i got a list box with a list called eur, chf and gbp

    when i switch from eur to chf it clears all enties i had in the textboxes in main form what i am trying to achieve is: if i working on say the euro list i want all the info in text boxes to be save in a text file called eur then when i switch list chf and do entries there it also saves to a text file called chf then when i go back to list eur list it brinks back all the data from the textfile and puts back in the appropriate textboxes
    Thnx In Advance

  5. #5
    Fanatic Member laserman's Avatar
    Join Date
    Jan 2002
    Location
    Wales U.K
    Posts
    775
    Do it this way using a commondialog1 control
    this will allow you to save in anew file where you want

    VB Code:
    1. Private Sub mnuFileSave_Click()
    2. CommonDialog1.Filter = "Text files,(*.txt)|*.txt|"
    3. CommonDialog1.ShowSave
    4. Open CommonDialog1.FileName For Output As #1
    5.  
    6. Print #1, Text1.Text
    7. Print #1, Label1
    8.  
    9. Close #1

  6. #6
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    if you want to use your first method, simply change the name of the output file. You can't save to the same file repeatedly.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

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