Display "No Internet Connection"

Hi,

I am working in VB 6. I want to display a message in a textbox as "No Internet Connection" when the computer is not connected with internet or got disconnected.

The below code is only useful when your network cable is unplugged but I want something which will show Text7.text = 1 when and the moment I am logging off from my broadband / client.

Please help.
Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias _
"InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Long, _
ByVal dwReserved As Long) As Long
Sub TestIt()
Text7.Text = InternetCheckConnection("http://www.google.com/", &H1, 0)
End Sub

Open in new window

LVL 9
suvmitraAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

JackOfPHCommented:
Is it possible for you to migrate to vb.net?
0
suvmitraAuthor Commented:
No..I am creating the entire application into VB 6.0 only. Please help.
0
nffvrxqgrcfqvvcCommented:
You can use InternetGetConnectedState. InternetCheckConnection can be called to determine if a connection to a specific destination can be established.
Option Explicit
 
Private Declare Function InternetGetConnectedState Lib "wininet" (ByRef dwflags As Long, ByVal dwReserved As Long) As Long
 
Public Function IsConnected() As Boolean
 
  Dim dwState As Long
  
  If InternetGetConnectedState(dwState, 0) Then
    IsConnected = True
  Else
    IsConnected = False
  End If
  
End Function
 
Private Sub Command1_Click()
 
  If IsConnected = True Then
    Debug.Print "Connected"
  Else
    Debug.Print "Not Connected"
  End If
  
End Sub

Open in new window

0
suvmitraAuthor Commented:
Nope, this one is also doing the same thing.
See what I want is, IF
WebBrowser1.Navigate (http://indiangeekforum.info/)
and this particular site displays itself into the webbrowser1..THEN
Timer1.Enabled = True
 
However, what is happening there is, I am logged out from my client but as I am using a LAN connection the internet connection is still there and it is showing me as connected.
So instead, what I want is if this particular website load itself into the webrowser1 then TEXTBOX1 should display as connected and the Timer Starts.
Please help.
 
 
0
suvmitraAuthor Commented:
Finally..we can do this by the following way.

Sub TestTimer()
On Error Resume Next
If Text8.Text = "http://indiangeekforum.info/" Then
Timer1.Enabled = True
Else
Timer1.Enabled = False
End If
End Sub
--
Private Sub Form_Load()
On Error Resume Next
Timer1.Enabled = False
WebBrowser1.Navigate ("http://indiangeekforum.info/")
End Sub
--
Private Sub cmdKey_Click()
On Error Resume Next
Text8.Text = (WebBrowser1.LocationURL)
Call TestTimer
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.