Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » VB.NET » General » Downloads
 
Add your own
alternative version

WebResourceProvider VB.NET style

, 30 Aug 2002
Ravi Bhavnani's WebResourceProvider ported to the .NET Framework
Public Class QuoteProvider

    ' QuoteProvider.vb
    '
    ' Written by Marcel Spring, ADVIS AG, Switzerland <marcel.spring@advis.ch>
    ' Copyright (c) 2002.  All Rights Reserved.
    '
    ' code adapted from original c++ library from
    ' Ravi Bhavnani <ravib@ravib.com>
    ' http:'www.codeproject.com/internet/WebResourceProvider.asp.
    ' Copyright (c) 2002.  All Rights Reserved.
    '
    ' This code may be used in compiled form in any way you desire. This
    ' file may be redistributed unmodified by any means PROVIDING it is 
    ' not sold for profit without the author's written consent, and 
    ' providing that this notice and the author's name and all copyright 
    ' notices remains intact. 
    '
    ' An email letting us know how you are using it would be nice as well. 
    '
    ' This code is provided "as is" with no expressed or implied warranty.
    ' The author accepts no liability for any damage/loss of business that
    ' this product may cause.
    '
    '
    ' Revision history:
    '
    ' 06 Jun 2002 - Initial release
    '------------------------------------------------------------------------------------------

    Inherits WebResourceProvider

    '==========================================================================================
    'Private stuff 
    '==========================================================================================

    '------------------------------------------------------------------------------------------
    Private mySymbol As String = ""
    Private myQuote As String


    '==========================================================================================
    'Public stuff 
    '==========================================================================================

    '------------------------------------------------------------------------------------------
    Public Property Symbol() As String
        Get
            Return mySymbol
        End Get
        Set(ByVal Value As String)
            mySymbol = Value
        End Set
    End Property

    Public ReadOnly Property Quote() As String
        Get
            If mySymbol <> "" Then
                Try
                    Me.FetchResource()
                Catch ex As Exception
                    Throw New System.Exception("Error fetching quote from Yahoo", ex)
                End Try
                If myQuote = "" Then
                    myQuote = "not found!"
                End If
                Return myQuote
            End If
        End Get
    End Property


    '==========================================================================================
    'Overriden methods from base class
    '==========================================================================================

    '------------------------------------------------------------------------------------------
    Overrides Sub ConstructUrl(ByRef myURL As String)
        Me.URL = [String].Format("http://finance.yahoo.com/q?h=1&s={0}&d=t", mySymbol)
    End Sub

    '------------------------------------------------------------------------------------------
    Overrides Sub ParseContent()
        myQuote = ""

        'get the quote
        If Not skipTo("Last Trade") Then
            Return
        End If
        If Not skipTo("<b>") Then
            Return
        End If
        If Not extractToExact("</b>", myQuote) Then
            Return
        End If

    End Sub

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Cello
Web Developer
Switzerland Switzerland
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141216.1 | Last Updated 31 Aug 2002
Article Copyright 2002 by Cello
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid