Results 1 to 4 of 4

Thread: [Resolved] Online text

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    33

    Resolved [Resolved] Online text

    Hey everyone

    I want to be able to make my program check a .txt file online for a certain string. If that string is something, it does a sub. If not, it doesnt do anything.

    How would i make it link up to that .txt file and get the string out of it?

    all that would be in the .txt is something like "Yes" or "No"...
    Last edited by Jonno12345; Jan 15th, 2005 at 04:37 PM. Reason: Resolved

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Online text

    Put an Inet control on your form then use the below code. HTH

    VB Code:
    1. Private Sub Command1_Click()
    2. Dim s as String
    3. Dim MyValue as String
    4. DownloadToFile "http://www.yoursite.com/myfile.txt", App.Path & "\myfile.txt"
    5.  
    6. 'Once file has been downloaded you need to open it and check for Yes/No
    7.  
    8.  
    9. Open App.Path & "\myfile.txt" For Input As #1 'Open text file
    10.  
    11. Line Input #1, s 'Read first line of text file
    12. MyValue = s 'This will either be Yes or No
    13.  
    14. Close #1 'Close text file
    15.  
    16. Kill App.Path & "\myfile.txt" 'Delete file once it's been used
    17.  
    18. End Sub
    19.  
    20. Public Sub DownloadToFile(sUrl As String, sFileName As String)
    21. Dim iID As Integer
    22. Dim b() As Byte
    23.  
    24.   'This download the URL to a byte array
    25.   b() = Inet1.OpenURL(sUrl, 1)
    26.  
    27.   ' Get a free file number
    28.   iID = FreeFile
    29.  
    30.   ' Open the local file in binary mode
    31.   Open sFileName For Binary As iID
    32.  
    33.   ' Save the byte array to the file
    34.   Put #iID, , b()
    35.  
    36.   ' Close the local file
    37.   Close iID
    38. End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    33

    Re: Online text

    Quote Originally Posted by lintz
    Put an Inet control on your form then use the below code. HTH

    VB Code:
    1. Private Sub Command1_Click()
    2. Dim s as String
    3. Dim MyValue as String
    4. DownloadToFile "http://www.yoursite.com/myfile.txt", App.Path & "\myfile.txt"
    5.  
    6. 'Once file has been downloaded you need to open it and check for Yes/No
    7.  
    8.  
    9. Open App.Path & "\myfile.txt" For Input As #1 'Open text file
    10.  
    11. Line Input #1, s 'Read first line of text file
    12. MyValue = s 'This will either be Yes or No
    13.  
    14. Close #1 'Close text file
    15.  
    16. Kill App.Path & "\myfile.txt" 'Delete file once it's been used
    17.  
    18. End Sub
    19.  
    20. Public Sub DownloadToFile(sUrl As String, sFileName As String)
    21. Dim iID As Integer
    22. Dim b() As Byte
    23.  
    24.   'This download the URL to a byte array
    25.   b() = Inet1.OpenURL(sUrl, 1)
    26.  
    27.   ' Get a free file number
    28.   iID = FreeFile
    29.  
    30.   ' Open the local file in binary mode
    31.   Open sFileName For Binary As iID
    32.  
    33.   ' Save the byte array to the file
    34.   Put #iID, , b()
    35.  
    36.   ' Close the local file
    37.   Close iID
    38. End Sub
    Thank you VERY much. Thats more perfect than a perfect thing thats perfect

  4. #4
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: [Resolved] Online text

    You're welcome

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