-
March 26th, 2014, 12:18 PM
#1
Weather Web Service
there are no errors showing on the code screen but when I debug it to test it and goes to receive, my message box saying "web service not available" pops up.
It is built with a Text Box for Zip entry, Combo box for Weather or forecast, lblForecast for return. Three buttons Submit, Clear, and Exit. Submit is the one button not working.
The methods are:
GetCityForecastByZIP ( ZIP As string ) As ForecastReturn
Allows you to get your City Forecast Over the Next 7 Days, which is updated hourly. U.S. Only
GetCityWeatherByZIP ( ZIP As string ) As WeatherReturn
Allows you to get your City's Weather, which is updated hourly. U.S. Only
I need an example or step by step to correct. I am new to VB and hitting this wall and feel I'm so close. Thank you in advance for your help im really struggling here.
At the" lblForecast.text = intZipCode.ToString & " " & strWeatherType " it is underlined with the hint variable intZipCode is used before it has been assigned a value. Same for strWeatherType.
Code:
Option Strict On
Public Class frmLocalWeather
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
'Connects to Web Services to give either the weather, temperature, or both for the selected City.
Dim wsWeatherReturn As New com.cdyne.wsf.Weather
Dim wsWeather1 As New com.cdyne.wsf.WeatherReturn
Dim intZipCode As String
Dim strTempType As String
Dim strWeatherType As String
Try
intZipCode = Convert.ToString(txtZip.Text)
wsWeather1 = wsWeatherReturn.GetCityWeatherByZIP("37066")
Catch Exception As FormatException
'Detects if information is missing
MsgBox("Select a Zip and Weather Type", , "Error")
Catch Exception As OverflowException
'This catch Block detects numbers that are to Large
MsgBox("Please enter Zip Code")
Catch Exception As SystemException
'This catch block detects a generic exception.")
MsgBox("Entry invalid. Please enter a valid Zip Code")
End Try
'Select Weather or Temperature
If (cboWeather.SelectedIndex > -1) Then
strTempType = CStr(cboWeather.SelectedIndex)
Try
Select Case strTempType
Case CStr(0)
wsWeather1 = wsWeatherReturn.GetCityWeatherByZIP("37066")
strWeatherType = " Temperature "
Case CStr(1)
wsWeather1 = wsWeatherReturn.GetCityWeatherByZIP("37066")
strWeatherType = " Weather "
Case CStr(2)
wsWeather1 = wsWeatherReturn.GetCityWeatherByZIP("37066")
strWeatherType = " Both "
End Select
'Produce Weather or temp
LblForecast.Text = intZipCode.ToString & " " & strWeatherType
Catch Exception As SystemException
MsgBox("Web Service Not Available", , "Error")
End Try
Else
MsgBox("Select a Zip and Weather type")
End If
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtZip.Text = ""
LblForecast.Text = ""
cboWeather.Text = ""
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Close()
End Sub
Private Sub frmLocalWeather_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Clear Forecast Label
LblForecast.Text = ""
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|