Adblock breaks this site

save file

Discussion in 'Programming General' started by bloodbaron20, Mar 27, 2009.

  1. bloodbaron20

    bloodbaron20 Newcomer

    Joined:
    Mar 6, 2008
    Posts:
    8
    Referrals:
    0
    Sythe Gold:
    0
    save file

    hi i got an question about saving a file,
    i got this code
    Code:
    Private Sub timer1_timer()
    Timer1.Enabled = False
    Open "c:\file path" + home.foto.Text + "\index.html" For Append As #1    ' Open file for output.
    Write #1, Index.Text
    ' Close before reopening in another mode.
    Close #1
    End Sub
    
    Private Sub Form_Load()
    Timer1.Enabled = True
    End Sub
    and it works but when i open the file there stands ""
    so how can i save the file withouth " " ?
     
  2. Darthatron

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0
    save file

    At the moment you would just be adding whatever is in the Index (bad name, btw) textbox to the end of a file, because that's what append does. This is bad because the file size will constantly increase. Append also adds "" to strings when you output them into a file.

    So, if you want a way around this you would use the "Binary" and "Put" method.

    Code:
    Dim LengthOfFile As Long
        Open "c:\file path" & home.foto.Text & "\index.html" For Binary As #1 'Open the file for editing.
        
            LengthOfFile = LOF(1) 'Get the current length of the file and store it in the "LengthOfFile" Long.
            
            Put #1, LengthOfFile + 1, Index.Text 'Write the data in the Index textbox to the end of the file.
            
        Close #1 'Close the file.
    If you want me to explain more, post.
     
< .batch | [QUESTION]log keys entered in java applet? >


 
 
Adblock breaks this site