Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

I would like to get a real-time quote from the Internet, then display the quote price in a textbox on a VB.Net Windows Form.

 

Here are the basic steps to get the quote manually:

 

1). Open IE 6.0, type in a URL at address location:

http://finance.yahoo.com/q/ecn?s=MSFT

 

2). It will display a real-time quote for Microsoft, such as

Last Trade: 28.22

 

======================

3). If you view the HTML Source page and search for "Last Trade:" string,

 

it will show the following line embedded inside lots of HTML codes.

-----------------------------------------------------------

Last Trade:</td><td class="yfnc_tabledata1"><b>28.22</b>

-----------------------------------------------------------

 

My question is how can you make a copy of this Microsoft last trade price (28.22) and display it in a textbox on VB.Net Windows Form?

 

Thanks in advance for your help,

Posted

Robby,

 

Thanks for your quick hint. I just looked at WebClient. There are three kinds of method available.

 

1). The DownloadData method downloads data from a resource and then returns a byte array.

2). The DownloadFile method downloads data from a resource to a local file.

3). The OpenRead method returns the data from the resource as a stream.

 

Which method do you recommand me to use in this case? There will be over thousands of HTML tags and words in a single web page, I just need copying one data (last trade: 28.22) from them.

 

 

 

 

look into using Net.WebClient()
  • Moderators
Posted

OpenRead will stream the contents of the page to you so you can parse it.

DownLoadFile allows you to download files such as images

 

here's a sample....

 

Dim sr As IO.StreamReader

Dim wc As New Net.WebClient()

sr = New IO.StreamReader(wc.OpenRead(THE_URL))

sim s as string

s = sr.ReadToEnd

sr.DiscardBufferedData()

sr.Close()

wc.Dispose()

's will contain all the html

Visit...Bassic Software
Posted

Robby,

 

Thanks a lot for your time and expert opinion.

 

Eric

 

 

OpenRead will stream the contents of the page to you so you can parse it.

DownLoadFile allows you to download files such as images

 

here's a sample....

 

Dim sr As IO.StreamReader

Dim wc As New Net.WebClient()

sr = New IO.StreamReader(wc.OpenRead(THE_URL))

sim s as string

s = sr.ReadToEnd

sr.DiscardBufferedData()

sr.Close()

wc.Dispose()

's will contain all the html

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...