It appears that you're running an Ad-Blocker. This site is monetized by Advertising and by ">User Donations; we ask that if you find this site helpful that you whitelist us in your Ad-Blocker, or make a ">Donation to help aid in operating costs.

using winsock you can get the local ip by saying winsock1.LocalIP and the remote host ip by saying winsock1.RemoteHostIP . not sure if that is exactly what you wanted, but maybe it will help. one way to detect when your computer connects to the internet would be to have the winsock control attempt to connect to remote machine. if it is successful then you know you have an internet connection, if not you are not connected. and ghost, this topic is on vb.

Using the winsock control you can get your local IP, but this is how you can detect whether you are connected to the internet and how:

Private Const INTERNET_CONNECTION_CONFIGURED = &H40Private Const INTERNET_CONNECTION_LAN = &H2Private Const INTERNET_CONNECTION_MODEM = &H1Private Const INTERNET_CONNECTION_OFFLINE = &H20Private Const INTERNET_CONNECTION_PROXY = &H4Private Const INTERNET_RAS_INSTALLED = &H10Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As LongPrivate Sub Form_Load() Dim Ret As Long Me.AutoRedraw = True 'retrieve the connection status InternetGetConnectedState Ret, 0& 'show the result If (Ret And INTERNET_CONNECTION_CONFIGURED) = INTERNET_CONNECTION_CONFIGURED Then Me.Print "Local system has a valid connection to the Internet, but it may or may not be currently connected." If (Ret And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN Then Me.Print "Local system uses a local area network to connect to the Internet." If (Ret And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM Then Me.Print "Local system uses a modem to connect to the Internet." If (Ret And INTERNET_CONNECTION_OFFLINE) = INTERNET_CONNECTION_OFFLINE Then Me.Print "Local system is in offline mode." If (Ret And INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY Then Me.Print "Local system uses a proxy server to connect to the Internet." If (Ret And INTERNET_RAS_INSTALLED) = INTERNET_RAS_INSTALLED Then Me.Print "Local system has RAS installed."End Sub