|
-
Oct 25th, 2007, 08:30 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Using A Timer
I'm using a third part OCX to check for an update via the internet. Unfortunately the error handling for when there is no connection (either no internet connection or the web site is down) that was built into it isn't functioning correctly and the program will hang. My idea was to use a timer and if it didn't find the web site in 5 seconds error out and pass a "flag" through an .INI file. Unfortunately it's not working as I'd hoped. Here is the code:
VB Code:
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 5000
WebVrChk1.Check 'Checks the site for version information.
End Sub
My problem is that even when the site is available it still waits 5 seconds and errors out. Is there a better way to wait for WebVrChk1.Check? Any help?
Thanks
Last edited by bat711; Oct 25th, 2007 at 08:34 PM.
-
Oct 26th, 2007, 01:32 AM
#2
Re: Using A Timer
If you need to check the internet connection availability, then you can use the InternetCheckConnection() API.
Example:
Code:
Private Const FLAG_ICC_FORCE_CONNECTION = &H1
Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: [email protected]
If InternetCheckConnection("http://www.allapi.net/", FLAG_ICC_FORCE_CONNECTION, 0&) = 0 Then
MsgBox "Connection to http://www.allapi.net/ failed!", vbInformation
Else
MsgBox "Connection to http://www.allapi.net/ succeeded!", vbInformation
End If
End Sub
-
Oct 26th, 2007, 12:36 PM
#3
Thread Starter
Addicted Member
Re: Using A Timer
Thanks, I didn't think of doing something like that.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|