I started using Yahoo\'s free weather API to get the weather data I need, but it seems each time I request a city weather data there is a chance that either I get updated data o
I have used the Yahoo Weather API XML format for years and noticed in that last couple of weeks this new bug. I tried to report the bug to https://developer.yahoo.com/weather/support but get a 404 page not found. I decided to parse the returned date if equal to current date to continue if not equal to re-call sub. this way I always get current weather but unfortunately that's a lot of unnecessary traffic / request maybe YDN will realize and fix. but without being able to report I don't know. I know this is not a fix but more a Band-Aid good luck!
Private Sub btnWeather_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWeather.Click
If InternetConnection() = False Then
MsgBox("No internet connection!", vbExclamation, "Oops!")
Exit Sub
Else
'MsgBox("Internet connection detected!", vbInformation, "Huray!")
btnWeather.Enabled = False
lblWorking.Text = "Working ..."
tbTries.Text = "1"
Try
Dim t As New clsWeather(Format(Me.TxtBoxZIP.Text), "f")
lblTodaysDate.Text = FormatDateTime(Now.Date, DateFormat.ShortDate)
tbHigh.Text = t.high & "°"
lblCity.Text = TxtBoxZIP.Text & " Weather "
tbLow.Text = t.Low & "°"
tbDay.Text = t.day
tbDate.Text = t.date1
tbCurrenttemp.Text = t.currenttemp & "°"
tbCurrentCode.Text = t.currentcode
tbForcastCode.Text = t.ForcastCode
tbSunrise.Text = t.Sunrise
tbSunset.Text = t.Sunset
tbWind.Text = CInt(Val(t.Wind)) & " mph"
tbHumidity.Text = CInt(Val(t.humidity))
imgWeather.Image = Image.FromFile(t.GetImage)
CodeName()
If t.currenttemp < 85 And t.currenttemp > 45 Then
lblFeelsLike.Text = ""
tbFeelsLike.Text = ""
End If
If t.currenttemp > 85 Then
lblFeelsLike.Text = "Heat Index:"
Dim Temp = t.currenttemp
Dim RH = CInt(Val(t.humidity))
tbFeelsLike.Text = (-42.379 + 2.04901523 * Temp) + (10.14333127 * RH) - (0.22475541 * Temp * RH) - (0.00683783 * Temp * Temp) - (0.05481717 * RH * RH) + (0.00122874 * Temp * Temp * RH) + (0.00085282 * Temp * RH * RH) - (0.00000199 * Temp * Temp * RH * RH)
Dim num As Decimal = CType(tbFeelsLike.Text, Decimal)
Me.tbFeelsLike.Text = String.Format("{0:n0}", num)
tbFeelsLike.Text = tbFeelsLike.Text & "°"
End If
If t.currenttemp < 45 Then
lblFeelsLike.Text = "Wind Chill:"
tbFeelsLike.Text = CInt(Val(t.Chill)) & "°"
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
Dim day As String = DateTime.Now.ToString("dd")
If day = tbDate.Text = True Then
tbDate1.Text = tbDate.Text
btnWeather.Enabled = True
lblWorking.Text = ""
Else
btnWeather_Click(sender, e)
tbTries.Text = tbTries.Text + 1
End If
End Sub