[RESOLVED] Help me open a file on the internet!
I wrote some code for checking if it can read a file that i have on my website. The file that the program is supposed to try to open is www.guitar.gratisplaneten.com/test.txt.
Why can't my program open the file? Is there some other way of doing this?
Here's the code of the function:
Function connected(hej)
On Error GoTo notconnected
Open "http://www.guitar.gratisplaneten.com/test.txt" For Input As #9
Close #9
Exit Function
notconnected:
If (MsgBox("The program cannot connect to the internet, check your internet and firewall settings and try again. To try again, press OK.", vbOKCancel, "No connection")) = vbOK Then
connected (1)
End If
End
End Function
Re: Help me open a file on the internet!
Hi cyber_alex
You can't just open a file off the internet, you will need to download it first.
Use the Inet control or a webbrowser to download the text file onto your computer, and then read it from there.
Re: Help me open a file on the internet!
but how do I then write a file to my website?
Re: Help me open a file on the internet!
and why can't I just open a file from my site, the internet browser can.
Re: Help me open a file on the internet!
Because your program isn't a internet browser!
If your website supports FTP then you can use the Inet control to upload a file to your website and download it
Re: Help me open a file on the internet!
Re: Help me open a file on the internet!
Click Project > Components > 'Microsoft Internet Transfer Control' > OK
Add the Inet control (which should be in the toolbox now) to your form.
When you want to download the data use
VB Code:
HTML = Inet1.OpenURL("http://www.guitar.gratisplaneten.com/test.txt")
Re: Help me open a file on the internet!