0

Hello I need a little help in my project. So program will crash if it executes a code that requires internet I want to learn how can I command my app to check if there is internet then proceed if there is internet and prompt the user to connect to internet if not connected to internet

Public Sub CheckForUpdates()
       If ProgressBar1.Value = 100 Then
           Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://dl.dropbox.com/u/46370133/Noter/Version.txt.txt")
           Dim response As System.Net.HttpWebResponse = request.GetResponse()
           Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
           Dim newestversion As String = sr.ReadToEnd()
           Dim currentversion As String = Application.ProductVersion
           If newestversion.Contains(currentversion) Then
               Button1.Text = ("You are up todate!")
               label2.text = ("You may now close this dialog")
           Else
               Button1.Text = ("Downloading update!")
               WebBrowser1.Navigate("http://dl.dropbox.com/u/46370133/Noter/Noter.exe")
               label2.text = ("You may now close this dialog")
           End If
       End If
Button
Button1.Enabled = False
       Button1.Text = "Checking for updates..."
       Timer1.Start()
       Label1.Text = ProgressBar1.Value
       CheckForUpdates()
timer
ProgressBar1.Increment(5)
               Label1.Text = ProgressBar1.Value
               If ProgressBar1.Value = 100 Then
                   Timer1.Stop()
                   If ProgressBar1.Value = 100 Then
                       Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("http://dl.dropbox.com/u/46370133/Noter/Version.txt.txt")
                       Dim response As System.Net.HttpWebResponse = request.GetResponse()
                       Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
                       Dim newestversion As String = sr.ReadToEnd()
                       Dim currentversion As String = Application.ProductVersion
                       If newestversion.Contains(currentversion) Then
                   Button1.Text = ("You are up todate!")
                   label2.text = ("You may now close this dialog")
                       Else
                   Button1.Text = ("Downloading update!")
                   WebBrowser1.Navigate("http://dl.dropbox.com/u/46370133/Noter/Noter.exe")
                   label2.text = ("You may now close this dialog")
                       End If
                   End If
               End If
Jose Miranda
  • 97
  • 1
  • 3
  • 8
  • 1
    possible duplicate of [Check Internet Connectivity](http://stackoverflow.com/questions/8800119/check-internet-connectivity) – sloth May 23 '14 at 11:16

1 Answers1

0

If My.Computer.Network.Ping("www.Google.com") Then

      MsgBox("Internet Ok")
    Else
      MsgBox("No Internet")

    End If
Creator
  • 1,502
  • 4
  • 17
  • 30