Link to home
Start Free TrialLog in
Avatar of al4629740
al4629740Flag for United States of America

asked on

Continue after an error

I have the following code in vb6 to check the current version of my software before it opens.

cData = Inet1.OpenURL("http://www.mywebsite.org/version.txt", 0)

The problem is that sometimes www.mywebsite.org is sometimes down and I don't want the program to get hung up on trying to locate an unreachable file.

When I recieve an error on the above site, what can I do to make the program continue
ASKER CERTIFIED SOLUTION
Avatar of Peter Kwan
Peter Kwan
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of al4629740

ASKER

How about this?

If InternetCheckConnection("http://www.mywebsite.org/", &H1, 0) = 1 Then

'Code goes here

end if
i would declare

Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias _
"InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Long, _
ByVal dwReserved As Long) As Long
InternetCheckConnection allows to check if a connection to
"http://www.mywebsite.org/" can be established.

It is not capable to check if the file "version.txt" on the web page "http://www.mywebsite.org/" exists.
To check if "www.mywebsite.org" is down and the file "version.txt" is reachable or unreachable
I recommend the "URLDownloadToFile" API. -See the attached code sample.
5.zip