Results 1 to 4 of 4

Thread: text file help

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    text file help

    How do i write to a text file saying the word "Blocked" using a text box and a command button. I also would like to know how to delete from a text file thats on a server. The file that needs the word written to is

    http://www.vbsoftware.biz/test.txt

    Hope someone can help me.

    Best Regards
    come back and mark your original post as resoved if your problem is fixed

    Jamie Garland

  2. #2
    Hyperactive Member Jenova's Avatar
    Join Date
    Feb 2006
    Location
    Googleplex
    Posts
    413

    Re: text file help

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     Dim iHandle     As Long
    5.    
    6.     iHandle = FreeFile()
    7.    
    8.     Open "<Path to File>" For Output As iHandle
    9.         Print #iHandle, Text1.Text ' The text property says "Blocked"
    10.     Close iHandle
    11. End Sub

    If the file has been posted on the internet and it is not yours then you will not be able to ammend it, however if this is yours and you are ammending the text file through a web page then yould use the above as a script for a web page that ammends the file. If this is your text file on your server then you will need to open replace "<Path to File>" with the path of the file.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Re: text file help

    When i try that code

    vb Code:
    1. Private Sub Command1_Click()
    2. Dim iHandle As Long
    3.  
    4. iHandle = FreeFile()
    5.  
    6. Open "http://www.vbsoftware.biz/disable/test.txt" For Output As iHandle
    7. Print #iHandle, Text1.Text ' The text property says "Blocked"
    8. Close iHandle
    9.  
    10. End Sub

    It says Bad filename or Number then

    highlights

    vb Code:
    1. Open "http://www.vbsoftware.biz/disable/test.txt" For Output As iHandle
    come back and mark your original post as resoved if your problem is fixed

    Jamie Garland

  4. #4
    Hyperactive Member Jenova's Avatar
    Join Date
    Feb 2006
    Location
    Googleplex
    Posts
    413

    Re: text file help

    Of course it does, the open statement expects a directory, not a URL which is what you have provided. The Open statement searches your PC for the directory and file not, not the internet. That is why you get bad file mode because it can not find what you have specified.

    You also need to take into account that the file you are looking to edit is stored on the internet. If this text file is stored on a server that you own then just use the directory where the file is stored on the server. If the server where this text file resides is 3rd Party (owned by someone else like phpBB) then you can't edit it.

    Also, when i went on to the link you provided, the text file was being displayed as a web page.

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