Solved

Continue after an error

Posted on 2012-04-02
6
254 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

821 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