Solved

Continue after an error

Posted on 2012-04-02
6
253 Views
Last Modified: 2012-04-06
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
0
Comment
Question by:al4629740
  • 3
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
Peter Kwan earned 250 total points
ID: 37799332
on error resume next
0
 
LVL 17

Assisted Solution

by:vb_elmar
vb_elmar earned 250 total points
ID: 37799414
You can constantly check the State of the Inet1 control using a timer.
Here is a small code sample.
2.zip
0
 

Author Comment

by:al4629740
ID: 37799424
How about this?

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

'Code goes here

end if
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:al4629740
ID: 37799427
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
0
 
LVL 17

Expert Comment

by:vb_elmar
ID: 37799759
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.
0
 
LVL 17

Expert Comment

by:vb_elmar
ID: 37801048
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
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

775 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question