How to connect

 Thirsty crow -
i want to create the program in VB which tell me when i connect internet it
dispaly the msgbox "You are conncected to Internet" and when disconnected
it display "Are you sure to Exit"


2 replies

I don't have solution but this code can deterimne if your network card is connected to any netork, but not the Internet.
My network card name is 'PCM1000 Wireless LAN Card Adapter'. Dind your name in Device manager and replace it.

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapter Where Name = 'PCM1000 Wireless LAN Card Adapter'")

For Each objItem in colItems
    Select Case objItem.NetConnectionStatus
        Case 0 strStatus = "Disconnected"
        Case 1 strStatus = "Connecting" 
        Case 2 strStatus = "Connected" 
        Case 3 strStatus = "Disconnecting" 
        Case 4 strStatus = "Hardware not present" 
        Case 5 strStatus = "Hardware disabled" 
        Case 6 strStatus = "Hardware malfunction" 
        Case 7 strStatus = "Media disconnected" 
        Case 8 strStatus = "Authenticating" 
        Case 9 strStatus = "Authentication succeeded" 
        Case 10 strStatus = "Authentication failed" 
        Case 11 strStatus = "Invalid address" 
        Case 12 strStatus = "Credentials required"
    End Select 
    Wscript.Echo "Net Connection Status: " & strStatus
Thanks brother for you help.