代码如下:Try
Dim mos As New System.Management.ManagementObjectSearcher("select * from win32_networkadapter where AdapterType='Ethernet 802.3'")
Dim moc As System.Management.ManagementObjectCollection = mos.Get
Dim mo As New System.Management.ManagementObject
If moc.Count = 0 Then
MsgBox("当前没有可用的网络适配器,请先安装它。", MsgBoxStyle.OKOnly, "提示")
Exit Sub
End If
For Each mo In moc
If Not mo.Item("NetConnectionStatus") Is Nothing Then
If Convert.ToInt16(mo.Item("NetConnectionStatus")) <> 2 Then
Dim errormsg() As String = {"Disconnected", "Connecting", "Connected", "Disconnecting", "Hardware not present", "Hardware disabled", "Hardware malfunction", "Media disconnected", "Authenticating", "Authentication succeeded", "Authentication failed"}
Dim n As Integer = CType(mo("NetConnectionStatus").ToString, Integer)
MsgBox("网络适配器不正常,请检查它!其当前状态为:" + errormsg(n), MsgBoxStyle.OKOnly, "提示")
iptxt.Text = "设备错误,状态为:" + errormsg(n)
change = False
Exit For
End If
End If
Next
Catch ex As Exception
MsgBox(Err.Description)
End Try不知道是什么原因。请大家给予帮助。
谢谢。
Dim mos As New System.Management.ManagementObjectSearcher("select * from win32_networkadapter where AdapterType='Ethernet 802.3'")
Dim moc As System.Management.ManagementObjectCollection = mos.Get
Dim mo As New System.Management.ManagementObject
If moc.Count = 0 Then
MsgBox("当前没有可用的网络适配器,请先安装它。", MsgBoxStyle.OKOnly, "提示")
Exit Sub
End If
For Each mo In moc
If Not mo.Item("NetConnectionStatus") Is Nothing Then
If Convert.ToInt16(mo.Item("NetConnectionStatus")) <> 2 Then
Dim errormsg() As String = {"Disconnected", "Connecting", "Connected", "Disconnecting", "Hardware not present", "Hardware disabled", "Hardware malfunction", "Media disconnected", "Authenticating", "Authentication succeeded", "Authentication failed"}
Dim n As Integer = CType(mo("NetConnectionStatus").ToString, Integer)
MsgBox("网络适配器不正常,请检查它!其当前状态为:" + errormsg(n), MsgBoxStyle.OKOnly, "提示")
iptxt.Text = "设备错误,状态为:" + errormsg(n)
change = False
Exit For
End If
End If
Next
Catch ex As Exception
MsgBox(Err.Description)
End Try不知道是什么原因。请大家给予帮助。
谢谢。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货