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

📄 class1.vb

📁 sql server report service的例子。给dw开发者
💻 VB
字号:
Public Class PlanetaryWeather

    'The line preceding function declaration asserts that this function needs to have FullTrust rights 
    ' even though it is called by a process that only has Execution rights.
    '
    'Also, the following line is required in AssemblyInfo.vb in order for the assert to work:
    '
    ' <Assembly: Security.AllowPartiallyTrustedCallers()> 

    <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Assert, Name:="FullTrust")> _
    Public Shared Function GetWeather(ByVal Abbrv As String) As String
        Dim resultStr As String = ""
        Dim locationToUse As String
        Dim wsx As net.webservicex.www.GlobalWeather
        Dim xmlResult As Xml.XmlDocument
        Dim tempStr As String
        Dim colonPos As Integer
        Dim mphPos As Integer
        Dim endPos As Integer

        wsx = New net.webservicex.www.GlobalWeather

        xmlResult = New Xml.XmlDocument

        ' Substitute city name for planet abbreviations
        If Abbrv = "AFU" Then
            locationToUse = "Minneapolis"
        ElseIf Abbrv = "BLN" Then
            locationToUse = "Miami"
        ElseIf Abbrv = "NOX" Then
            locationToUse = "Anchorage"
        ElseIf Abbrv = "RKM" Then
            locationToUse = "Boston"
        ElseIf Abbrv = "SLN" Then
            locationToUse = "New York"
        Else
            locationToUse = "Phoenix"
        End If

        xmlResult.LoadXml(wsx.GetWeather(locationToUse, "United States"))

        tempStr = xmlResult.SelectSingleNode("//Temperature").InnerXml

        resultStr = "Temperature: " & tempStr.Substring(tempStr.IndexOf("(") + 1, tempStr.IndexOf(")") - tempStr.IndexOf("(") - 1)

        tempStr = xmlResult.SelectSingleNode("//SkyConditions").InnerXml

        resultStr = resultStr & " Sky Conditions: " & tempStr

        tempStr = xmlResult.SelectNodes("//Wind")(0).InnerXml.Replace("from the ", "").Replace("at", "at:")
        colonPos = tempStr.IndexOf(":")
        mphPos = tempStr.IndexOf("MPH")
        endPos = tempStr.IndexOf(") gust")
        If endPos = -1 Then
            endPos = tempStr.IndexOf("):")
        End If
        tempStr = tempStr.Substring(0, colonPos + 2) & tempStr.Substring(mphPos + 5, endPos - (mphPos + 5))
        resultStr = resultStr & " Wind Conditions: " & tempStr

        Return resultStr
    End Function
End Class

⌨️ 快捷键说明

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