Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleSee if your computer is connected to the network.
Keywordsnetwork, connection, connected, Internet
CategoriesInternet
 
Use the winsock control's bind method.

This program uses the VB6 SP5 version of the Winsock control because that is the version I have on my machine. If you have VB4, remove the control and replace it with the VB4 version.

Note that this method seems to get confused if your machine is a network server. In particular if the machine is a personal Web server, the routine thinks you are connected to the network.

 
Private Sub Form_Load()
    If OnTheNet Then
        lblConnectInfo.Caption = "Connected"
    Else
        lblConnectInfo.Caption = "Not connected"
    End If
End Sub

Private Function OnTheNet() As Boolean
    Winsock1.Close
    Winsock1.Bind
    If Winsock1.LocalIP = "" Then
        OnTheNet = False
    Else
        OnTheNet = True
    End If
End Function
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated