|
-
Jan 15th, 2005, 01:51 PM
#1
Thread Starter
Member
[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
-
Jan 15th, 2005, 04:09 PM
#2
Re: Online text
Put an Inet control on your form then use the below code. HTH 
VB Code:
Private Sub Command1_Click()
Dim s as String
Dim MyValue as String
DownloadToFile "http://www.yoursite.com/myfile.txt", App.Path & "\myfile.txt"
'Once file has been downloaded you need to open it and check for Yes/No
Open App.Path & "\myfile.txt" For Input As #1 'Open text file
Line Input #1, s 'Read first line of text file
MyValue = s 'This will either be Yes or No
Close #1 'Close text file
Kill App.Path & "\myfile.txt" 'Delete file once it's been used
End Sub
Public Sub DownloadToFile(sUrl As String, sFileName As String)
Dim iID As Integer
Dim b() As Byte
'This download the URL to a byte array
b() = Inet1.OpenURL(sUrl, 1)
' Get a free file number
iID = FreeFile
' Open the local file in binary mode
Open sFileName For Binary As iID
' Save the byte array to the file
Put #iID, , b()
' Close the local file
Close iID
End Sub
-
Jan 15th, 2005, 04:37 PM
#3
Thread Starter
Member
Re: Online text
 Originally Posted by lintz
Put an Inet control on your form then use the below code. HTH
VB Code:
Private Sub Command1_Click()
Dim s as String
Dim MyValue as String
DownloadToFile "http://www.yoursite.com/myfile.txt", App.Path & "\myfile.txt"
'Once file has been downloaded you need to open it and check for Yes/No
Open App.Path & "\myfile.txt" For Input As #1 'Open text file
Line Input #1, s 'Read first line of text file
MyValue = s 'This will either be Yes or No
Close #1 'Close text file
Kill App.Path & "\myfile.txt" 'Delete file once it's been used
End Sub
Public Sub DownloadToFile(sUrl As String, sFileName As String)
Dim iID As Integer
Dim b() As Byte
'This download the URL to a byte array
b() = Inet1.OpenURL(sUrl, 1)
' Get a free file number
iID = FreeFile
' Open the local file in binary mode
Open sFileName For Binary As iID
' Save the byte array to the file
Put #iID, , b()
' Close the local file
Close iID
End Sub
Thank you VERY much. Thats more perfect than a perfect thing thats perfect
-
Jan 15th, 2005, 04:38 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|