Results 1 to 8 of 8

Thread: [RESOLVED] Time Taken To Download Web Page!

  1. #1

    Thread Starter
    Frenzied Member arpan_de's Avatar
    Join Date
    Oct 2005
    Location
    Mumbai, India
    Posts
    1,394

    Resolved [RESOLVED] Time Taken To Download Web Page!

    I am using the Microsoft Internet Control to create a web browser. I did like to find out how much time does it take for a web page to download. How do I accomplish this?

    The downloading time calculated should be as precise as possible.
    Last edited by arpan_de; Mar 29th, 2006 at 06:29 PM.


    ARPAN

    IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!

    NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!

    PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?

  2. #2
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068

    Re: Time Taken To Download Web Page!

    Use the DateDiff() function....
    At the start of your function get Now..
    VB Code:
    1. Dim This
    2. This = Now
    3. 'Load page here....
    4. TimeElapsed = DateDiff("s", Now & This) 'Gives you the difference in Seconds.
    That should do it.

    Also, you should put a Do Until loop around loading the page, so it won't calculate the time until it's done.
    Last edited by Spajeoly; Mar 29th, 2006 at 07:06 PM. Reason: Forgot something

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Time Taken To Download Web Page!

    Have a module level variable (lets call it nNavigationTime in this example) that you assign the return value of GetTickCount before you navigate to a new URL. You can then get the time it took by adding this code in the DocumentComplete event.
    VB Code:
    1. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    2.     If (pDisp Is WebBrowser1.Object) Then
    3.         nNavigationTime = GetTickCount - nNavigationTime
    4.         MsgBox "It took " & nNavigationTime / 1000 & " seconds to download this page"
    5.     End If
    6. End Sub

  4. #4
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068

    Re: Time Taken To Download Web Page!

    Quote Originally Posted by Joacim Andersson
    Have a module level variable (lets call it nNavigationTime in this example) that you assign the return value of GetTickCount before you navigate to a new URL. You can then get the time it took by adding this code in the DocumentComplete event.
    VB Code:
    1. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    2.     If (pDisp Is WebBrowser1.Object) Then
    3.         nNavigationTime = GetTickCount - nNavigationTime
    4.         MsgBox "It took " & nNavigationTime / 1000 & " seconds to download this page"
    5.     End If
    6. End Sub
    Well, that works too... =\

  5. #5

    Thread Starter
    Frenzied Member arpan_de's Avatar
    Join Date
    Oct 2005
    Location
    Mumbai, India
    Posts
    1,394

    Re: Time Taken To Download Web Page!

    But what is this GetTickCount?


    ARPAN

    IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!

    NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!

    PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Time Taken To Download Web Page!

    Quote Originally Posted by arpan_de
    But what is this GetTickCount?
    Oh sorry. It's an API function.
    VB Code:
    1. Private Declare Function GetTickCount Lib "kernel32.dll" () As Long

  7. #7

    Thread Starter
    Frenzied Member arpan_de's Avatar
    Join Date
    Oct 2005
    Location
    Mumbai, India
    Posts
    1,394

    Re: Time Taken To Download Web Page!

    But under which sub in the Module should nNavigationTime be assigned the return value of GetTickCount? Is this correct?
    VB Code:
    1. '[u]Form Code[/u]
    2. Private Sub wWeb_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
    3.     Call TimeElapsed
    4. End Sub
    5.  
    6. '[u]Module Code[/u]
    7. Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
    8. Public nNavigationTime As Long
    9.  
    10. Public Sub TimeElapsed()
    11.     nNavigationTime = GetTickCount
    12. End Sub


    ARPAN

    IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!

    NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!

    PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?

  8. #8

    Thread Starter
    Frenzied Member arpan_de's Avatar
    Join Date
    Oct 2005
    Location
    Mumbai, India
    Posts
    1,394

    Re: Time Taken To Download Web Page!

    OK......OK......I got it Joacim!


    ARPAN

    IF YOU HAVE AN APPLE & I HAVE AN APPLE AND WE EXCHANGE THE APPLES, THEN YOU & I WILL STILL HAVE ONE APPLE BUT IF YOU HAVE AN IDEA & I HAVE AN IDEA AND WE EXCHANGE OUR IDEAS, THEN EACH OF US WILL HAVE TWO IDEAS!

    NOTHING IS IMPOSSIBLE IN THIS WORLD.....EVEN THE WORD IMPOSSIBLE SAYS I'M POSSIBLE!

    PRACTICE MAKES A MAN PERFECT BUT NOBODY IS PERFECT; SO WHY PRACTICE?

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