⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 weather.aspx.vb

📁 Programming Web and Desktop Applications in ADO .NET and ASP .NET
💻 VB
字号:
Public Class WebForm1
    Inherits System.Web.UI.Page
    Protected WithEvents Label2 As System.Web.UI.WebControls.Label
    Protected WithEvents txtZipCode As System.Web.UI.WebControls.TextBox
    Protected WithEvents lblForecast As System.Web.UI.WebControls.Label
    Protected WithEvents btnWeather As System.Web.UI.WebControls.Button
    Protected WithEvents chkOutputOption As System.Web.UI.WebControls.CheckBox
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub btnWeather_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWeather.Click
        'Gets the Weather for a Week
        Dim objWeather As New com.unisysfsp.weather.WeatherServices()

        If Not chkOutputOption.Checked Then
            'Show Forecast by Day
            Dim objForecast As New com.unisysfsp.weather.WeatherForecast()
            Dim objDayForecast() As com.unisysfsp.weather.DailyForecast

            Try
                objForecast = objWeather.GetWeather(txtZipCode.Text)
                objDayForecast = objForecast.DayForecast

                Dim intCount As Integer

                lblForecast.Text = "<Font Color=Red>City: " & objForecast.CityShortName & "</Font><br>"
                lblForecast.Text += "Sunrise: " & objForecast.Sunrise & "<br>"
                lblForecast.Text += "Sunset: " & objForecast.Sunset & "<br>"
                lblForecast.Text += "Current Time: " & objForecast.Time & "<br>"

                'This loop produces actual forecast contained in objDayForecast array
                For intCount = 0 To UBound(objDayForecast)
                    lblForecast.Text += "Day: <Font Color=Red>" & objDayForecast(intCount).Day & "</Font><br>"
                    lblForecast.Text += "<Font Color=Blue>Forecast</Font>: " & LCase(objDayForecast(intCount).Forecast) & "<br>"
                    lblForecast.Text += "Low Temp: " & objDayForecast(intCount).LowTemp & "<br>"
                    lblForecast.Text += "High temp: " & objDayForecast(intCount).HighTemp & "<p>"
                Next
            Catch
                'Error Found! Zip code is invalid
                lblForecast.Text = "Invalid Zip Code! Please try again"
            Finally
                'Destroy the objects
                objWeather = Nothing
                objForecast = Nothing
            End Try
        Else
            'Show Raw Forecast
            lblForecast.Text = objWeather.GetWeatherText(txtZipCode.Text)
        End If
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -