‘把以下文件拷贝到 模块文件中
Module Mdl_ConnectTest
'--引用(例子)
'If ConnectTest("192.168.1.3") = True Then
' MsgBox("ok", MsgBoxStyle.Information)
' Else
' MsgBox("fail", MsgBoxStyle.Exclamation)
' End If
#Region "——连接测试:避免等待时间过长——"
Dim bConnect As Boolean
Dim BgWorker1 As New System.ComponentModel.BackgroundWorker
Dim ServerIP As String
'''
''' 测试连接:True-连接成功,False-连接失败
''' 参数[必选]:服务器IP
''' 参数[可选]:等待超时时间(秒),默认为1.2秒
'''
'''
'''
Function ConnectTest(ByVal varServerIP As String, Optional ByVal varTimeout As Decimal = 1.2) As Boolean
AddHandler BgWorker1.DoWork, AddressOf BgWorker1_DoWork
Dim g As Integer
Dim k As Integer
Try
If varServerIP = "" Then
Exit Function
End If
ServerIP = varServerIP
If varTimeout