Verificar Conexion Internet con VB.NET

noviembre 6, 2009 at 9:22 pm Deja un comentario

Muchas veces nuestra aplicacion .NET debe verificar si tiene una conexión a internet activa, la siguiente función nos devuelve True si hay conexión o False si no hay conexión.

Código VB.NET

Public Function isOnline() As Boolean
Dim Url As New System.Uri(“http://www.google.com/”)
Dim oWebReq As System.Net.WebRequest
oWebReq = System.Net.WebRequest.Create(Url)
Dim oResp As System.Net.WebResponse
Try
oResp = oWebReq.GetResponse
oResp.Close()
oWebReq = Nothing
Return True
Catch ex As Exception
oResp.Close()
oWebReq = Nothing
Return False
End Try
End sub

  1. Public Function IsConnectionAvailable() As Boolean
  2. Dim objUrl As New System.Uri(“http://www.yoursite.com/”)
  3. Dim objWebReq As System.Net.WebRequest
  4. objWebReq = System.Net.WebRequest.Create(objUrl)
  5. Dim objResp As System.Net.WebResponse
  6. Try
  7. objResp = objWebReq.GetResponse
  8. objResp.Close()
  9. objWebReq = Nothing
  10. Return True
  11. Catch ex As Exception
  12. objResp.Close()
  13. objWebReq = Nothing
  14. Return False
  15. End Try
  16. End sub

Entrada archivada en:Programacion .NET. Etiquetas:.

Eliminar cola de mensajes de un servidor de correo Postfix Desarrollo de Aplicaciones móviles con J2ME Parte I

Deja un comentario

Fill in your details below or click an icon to log in:

Logo de WordPress.com

You are commenting using your WordPress.com account. Log Out / Cambiar )

Twitter picture

You are commenting using your Twitter account. Log Out / Cambiar )

Facebook photo

You are commenting using your Facebook account. Log Out / Cambiar )

Connecting to %s

Trackback este articulo  |  Suscríbete a los comentarios vía RSS Feed


Calendario

noviembre 2009
L M X J V S D
    dic »
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Mensajes recientes


Seguir

Get every new post delivered to your Inbox.