Irrespective of how a user connects to the internet (LAN/Modem/DSL etc.), this is how I am finding the connection speed & the amount of data sent & received but I don't think it gives the correct results especially the connection speed (Note: rtfNetStats is a RichTextBox control & tmrNetStats & tmrNetSpeed are 2 Timer controls):

Code:
Option Explicit
Public Length       As Long
Public seconds      As Long
Private SelFunction As Byte

Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll" Alias "InternetGetConnectedStateExA" (ByRef lpdwFlags As Long, ByVal lpszConnectionName As String, ByVal dwNameLen As Long, ByVal dwReserved As Long) As Long

Public Enum EIGCInternetConnectionState
    INTERNET_CONNECTION_MODEM = &H1&
    INTERNET_CONNECTION_LAN = &H2&
    INTERNET_CONNECTION_PROXY = &H4&
    INTERNET_RAS_INSTALLED = &H10&
    INTERNET_CONNECTION_OFFLINE = &H20&
    INTERNET_CONNECTION_CONFIGURED = &H40&
End Enum

Public Property Get InternetConnected(Optional ByRef eConnectionInfo As EIGCInternetConnectionState, Optional ByRef sConnectionName As String) As Boolean
    Dim lR       As Long
    Dim iPos     As Long
    Dim dwFlags  As Long
    Dim sNameBuf As String
    
    sNameBuf = String$(513, 0)
    lR = InternetGetConnectedStateEx(dwFlags, sNameBuf, 512, 0&)
    eConnectionInfo = dwFlags
    iPos = InStr(sNameBuf, vbNullChar)
    If (iPos > 0) Then
        sConnectionName = Left$(sNameBuf, iPos - 1)
    ElseIf Not (sNameBuf = String$(513, 0)) Then
        sConnectionName = sNameBuf
    End If
    InternetConnected = (lR = 1)
End Property

Private Sub Form_Activate()
    Dim ConnSpeed  As Long
    Dim sMsg       As String
    Dim sName      As String
    Dim bConnected As Boolean
    Dim eR         As EIGCInternetConnectionState
    
    bConnected = InternetConnected(eR, sName)

    If ((eR And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM) Then
        sMsg = sMsg & "Connection: Modem" & vbCrLf
    End If
    If ((eR And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN) Then
        sMsg = sMsg & "Connection: LAN" & vbCrLf
    End If
    If ((eR And INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY) Then
        sMsg = sMsg & "Connection: (via) Proxy" & vbCrLf
    End If
    If ((eR And INTERNET_CONNECTION_OFFLINE) = INTERNET_CONNECTION_OFFLINE) Then
        sMsg = sMsg & "Connection: Off-line" & vbCrLf
    End If
    If ((eR And INTERNET_CONNECTION_CONFIGURED) = INTERNET_CONNECTION_CONFIGURED) Then
        sMsg = sMsg & "Configured: Yes" & vbCrLf
    Else
        sMsg = sMsg & "Configured: No" & vbCrLf
    End If
    If ((eR And INTERNET_RAS_INSTALLED) = INTERNET_RAS_INSTALLED) Then
        sMsg = sMsg & "System has RAS installed." & vbCrLf
    End If
   
    If (bConnected) Then
        rtfNetStats.Text = sMsg
    Else
        rtfNetStats.Text = "Not Connected: " & sName & vbCrLf & vbCrLf & sMsg
    End If
    
    Dim TCP As PMIB_TCPSTATS
    If (GetTcpStatistics(TCP) = NO_ERROR) Then
        rtfNetStats.Text = rtfNetStats.Text & vbCrLf & "Bytes Received: " & TCP.dwInSegs / 1000 & " KB"
        rtfNetStats.Text = rtfNetStats.Text & vbCrLf & "Bytes Sent: " & TCP.dwOutSegs / 1000 & " KB"
    Else
        MsgBox "Could not get TCP statistics!", vbExclamation, "Error!"
        tmrNetStats.Enabled = False
    End If

    SelFunction = 0
    tmrNetStats.Enabled = True
    seconds = 0
    tmrNetSpeed.Enabled = True

    Length = frmWebBrowser.wWeb.document.fileSize * 8

    If (seconds = 0) Then
        seconds = 1
    End If

    ConnSpeed = Round((Length / seconds) / 1024, 2)
    rtfNetStats.Text = rtfNetStats.Text & vbCrLf & vbCrLf & "Connection Speed: " & ConnSpeed & " kbps"
End Sub

Private Sub tmrNetSpeed_Timer()
    If (frmNetStats.Visible = True) Then
        seconds = seconds + 1
        tmrNetSpeed.Enabled = True
    End If
End Sub
I use a LAN connection to access the Internet but even when I am not connected to the Net, the above code never says that I am not connected to the Net. Also the connection speed usually hovers at the 1000 KBPS mark whereas the actual speed is far lesser than 1000 KBPS. Can someone please help me out with this?