Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File transfer problem!? 1

Status
Not open for further replies.

chriisb

Programmer
Mar 13, 2003
28
US
I'm trying to write a code to get the text version of a website that is quite large (about 150,000 characters) but whenever I try I only get the first 3848 characters. Does anyone know what I'm doing wrong? My code to get the data is

textbox1.text = Inet1.OpenURL(" & list)

where the string "list" is a list of stocks that I want to recieve information on.
 
I also tried copying the code and adjusting just a couple things to make it work in VB 6.0 and I still have the same problem
 
Microsoft Internet Transfer Control 6.0? Is that what you mean?
 
Short version
I played with this a bit and got roughly the same results as you did, which is, it only returned the first stock I selected, not all of them. I changed things a bit and was able to get all the quotes. Instead of a putting the text into textbox, use a RichTxtBox.

Long version
I'm a little more partial to the WebBrowser [COLOR=000090](Microsoft Web Browser - shdocvw.dll)[/color] as it seems easier to work with, so I used that instead. Here's what I did:

- Opened a new workbook
- Opened Visual Basic Editor (ALT+F11)
- Inserted a UserForm
- Right-clicked the toolbox, selected [COLOR=000090]
Code:
Additional Controls...
[/color]
- Added the [COLOR=000090]
Code:
Microsoft Rich Textbox Control
[/color] (richtx32.ocx)
and the [COLOR=000090]
Code:
Microsoft Web Browser
[/color](shdocv.dll) to the toolbox
- Added the RichTextBox and WebBrowser controls to the UserForm
- Inserted a module
- Added the following code to the module:

Code:
Sub getUnparsedStockQuotes()
   Dim stockQuotes(20)     As String
   Dim myList           As String
   Dim URL              As String
   Dim idx              As Integer
   
   stockQuotes(1) = "AMD"
   stockQuotes(2) = "INTC"
   stockQuotes(3) = "^DJI"
   stockQuotes(4) = "^IXIC"
   stockQuotes(5) = "GE"
   
   For idx = 1 To UBound(stockQuotes)
      If stockQuotes(idx) <> &quot;&quot; Then
         If idx = 1 Then
            myList = stockQuotes(idx)
         Else
            myList = myList & &quot;+&quot; & stockQuotes(idx)
         End If
      End If
   Next
   
   URL = &quot;[URL unfurl="true"]http://finance.yahoo.com/q?d=t&s=&quot;[/URL] & myList
   Call Get_Info_Using_Normal_Method(URL)
   'UserForm1.Show
End Sub
 

Public Sub Get_Info_Using_Normal_Method(URL As String)
   With UserForm1
      .WB.Navigate URL
      Do Until .WB.ReadyState = READYSTATE_COMPLETE
         DoEvents
      Loop
      .rtf1.Text = UserForm1.WB.Document.documentElement.outerText
      '.rtf1.Text = UserForm1.WB.Document.documentElement.innerHTML
   End With
End Sub

Now all you have to do is parse out the info you want.
I commented out the UserForm1.Show statement, because there is no real reason to show the text.
I threw in the commented out line about the HTML code, in case that's what you're really after.

Since a simple Google query, such as Excel stock quotes turns up a lot of pre-written code examples. I assume this is either for a school project, your own edification, or a very specific need.

Stephen F. Van Buren
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top