Results 1 to 3 of 3

Thread: [RESOLVED] Using A Timer

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Chicago
    Posts
    136

    Resolved [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:
    1. Private Sub Form_Load()
    2.    
    3.     Timer1.Enabled = True
    4.     Timer1.Interval = 5000
    5.     WebVrChk1.Check         'Checks the site for version information.
    6.  
    7. 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.
    CodeBank: Launch IE

  2. #2
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Chicago
    Posts
    136

    Re: Using A Timer

    Thanks, I didn't think of doing something like that.
    CodeBank: Launch IE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width