[VB] Check Internet Access

Solved
Anonymous user -  
Demonnya Posted messages 27 Status Member -
Hello,

In VB, I would like to know how to test if the PC is connected to the INTERNET. I already know the method My.Computer.Network.IsAvailable, but this only tests the connection to a NETWORK.

I eventually found the InternetGetConnectedState method but do not understand how to use it.

If you can reply to me or know another method, please let me know!

Thank you!

2 answers

Demonnya Posted messages 27 Status Member 20
 


'|||||||||||||||||||||||||||||||||||||||||||||||||||||
If My.Computer.Network.IsAvailable Then
MsgBox("Connected.")
Else
MsgBox("Not connected.")
End If
'|||||||||||||||||||||||||||||||||||||||||||||||||||||

(non essayé)
1
Myster62 Posted messages 5 Status Member
 
A little search is enough:

Option Explicit
Function Connection()
Set WshShell = CreateObject("WScript.Shell")
PINGFlag = Not CBool(WshShell.run("ping -n 1 www.google.it",0,True))
If PINGFlag = True Then
'Successful ping
Connection = True
Else
'Unsuccessful ping
Connection = False
End If
End Function

Dim Result : Result = Connection()

Source: http://www.visualbasicscript.com/VBS-to-check-for-active-internet-connection-m65481.aspx

--
Twibook.eu | The hyper community social network! - Free chat - Chat without registration - Teen chat - Adult chat
-7