Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 检查互联网连接是否不起作用_Vb.net_Visual Studio 2015 - Fatal编程技术网

Vb.net 检查互联网连接是否不起作用

Vb.net 检查互联网连接是否不起作用,vb.net,visual-studio-2015,Vb.net,Visual Studio 2015,我正在使用Windows10。我不知道操作系统是否会影响代码,但在我的表单上有一个标签和一个计时器。在计时器中,代码为: If System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable = True Then LabelTest.Text = "You are connected to the internet!" Else LabelTest.Text = "You are offline"` E

我正在使用Windows10。我不知道操作系统是否会影响代码,但在我的表单上有一个标签和一个计时器。在计时器中,代码为:

If System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable = True Then
    LabelTest.Text = "You are connected to the internet!" 
Else
    LabelTest.Text = "You are offline"`
End If

所以,这个计时器应该检查你是否连接到互联网,但是当我尝试代码时,它似乎不起作用。我试着拔出以太网电缆,甚至关掉我的路由器。标签上仍然写着:您已连接到internet,是的,一旦表单打开,计时器就会启动。我想知道如何解决这个问题。谢谢大家!

您可以使用作为框架一部分的应用程序事件,而不是使用计时器。但不管怎样,这都不会告诉你是否连接到互联网。要做到这一点,您可能需要PING一些不同的、不相关的网站,如google和Microsoft。您是否尝试禁用您的网络适配器?是的,我这样做了,但不起作用。