|
ลองทดสอบการเชื่อมต่อดูก่อนครับ ...
- ''' <summary>
- ''' check for a existing internet connection to some url.
- ''' </summary>
- ''' <returns>True if it's exist</returns>
- Public Shared Function isConnected(ByVal strURL As String) As Boolean
- Try
- Dim addresslist As IPAddress() = Dns.GetHostAddresses(strURL)
- ' | ' addresslist holds a list of ipadresses to google
- ' | ' e.g 173.194.40.112 |
- ' | ' .116 |
- If addresslist(0).ToString().Length > 6 Then
- Return True
- Else
- Return False
- End If
- Catch ex As Sockets.SocketException
- ' | ' You are offline |
- ' | ' the host is unkonwn |
- Return False
- Catch ex As Exception
- Return False
- End Try
- End Function
คัดลอกไปที่คลิปบอร์ด
- If isConnected(TextBox1.Text) Then
- MessageBox.Show("Connect OK", "Report Status", MessageBoxButtons.OK, MessageBoxIcon.Information)
- Else
- MessageBox.Show("Can't connect.", "Report Status", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
- End If
คัดลอกไปที่คลิปบอร์ด
|
|