Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

Opening files on the web

Hi,

I have a program that uses a data file that I would like to be updatable from the web. I don't want the user to have to use an internet browser, but to be able to click a button and the file is downloaded onto there computer.

Or something like:

Open "http://www.address.com/file.dat" For Output as #1

That code wouldnt work but how could it be changed to work?

Thanks,
Chris
0
chrispadbury
Asked:
chrispadbury
  • 3
1 Solution
 
J-ManCommented:
'You need to place a command button (Command1) and an inet control (Inet1) on your form.
'The user will also need an active internet connection.
Private Sub Command1_Click()
Dim strMyData as String
Inet1.URL = "http://www.address.com/file.dat"
Inet1.Password = ""
Inet1.UserName = ""
strMyData = Inet1.OpenURL
Open ("C:\TheFilePath" & "\file.dat") For Binary Access Write As #1
Put #1, , strMyData
Close #1
End Sub
0
 
J-ManCommented:
P.S. I'm assuming your datafile is ascii (text).
0
 
chrispadburyAuthor Commented:
That's Great it works a treat. Is there some code to check that the internet is connected and if not to prompt the user to connect (like you get when you open a web browser).

Thanks,
Chris
0
 
J-ManCommented:
I'm glad it works.  I'd appreciate it if you would click the "Accept this answer" button so I get credit for it.  As an added incentive, I'll answer your other question for no extra points.

Here is a short working example of determining if an internet connection exists.

http://abstractvb.com/code.asp?A=1073

Note: I'm not sure if this can tell the difference between an internet connection and an active LAN connection.  You might need to experiment.  Also, MSDN (msdn.microsoft.com) might have more info on the InternetAttemptConnect function in the wininet library.
Also, replace the msgbox by calling the dialup connection if you want it to connect automatically.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now