JKB
08-01-2014, 01:36 AM
Hi guys! Trying something new, i would like to use some information from a source code (from yahoo.finance on some stocks).
To do this i've found out that i can use the instr to locate positions in the html string i've created (sHtml_Yahoofinance, contains the full source code). Now, what i would like to do is to "print" the truncated source code in my textbox (Textbox1) so that i can see what im doing!
This however is not going as smooth as i hoped for, it doesnt seem to change the source code one bit... Can you guys explain to me what im doing wrong?
Private Sub CommandButton1_Click()
Dim label_start As Label
label_start:
Dim objIE As Object: Set objIE = CreateObject("Internetexplorer.application")
objIE.Top = 0
objIE.Left = 0
objIE.Width = 800
objIE.Height = 600
objIE.Visible = False
On Error Resume Next
objIE.Navigate (My link - Cant display this due to forum-rules.)
Do
DoEvents
If Err.Number <> 0 Then
objIE.Quit
Set objIE = Nothing
GoTo label_start:
End If
'Loading the source code
Loop Until objIE.ReadyState = 4 '4 indicates that page is completely loaded
Dim sHtml_YahooFinance As String
sHtml_YahooFinance = objIE.Document.body.innerHTML
'parsing the html string
If InStr(sHtml_YahooFinance, "yfs_pp0_") > 0 Then
sHtml_YahooFinance = Mid(sHtml_YahooFinance, InStr(sHtml_YahooFinance, "yfs_pp0_"), sHtml_YahooFinance) 'I want it to truncate where "yfs_pp0_" is located.
UserForm1.TextBox1.Text = sHtml_YahooFinance 'here im printing in Textbox1 after the source code has been edited, i think...
End If
End Sub
If i look in Textbox1, i see the same result, whether i remove/keep the line where i truncate... Could anybody enlighten me?
Hope you have a good day!
JKB
To do this i've found out that i can use the instr to locate positions in the html string i've created (sHtml_Yahoofinance, contains the full source code). Now, what i would like to do is to "print" the truncated source code in my textbox (Textbox1) so that i can see what im doing!
This however is not going as smooth as i hoped for, it doesnt seem to change the source code one bit... Can you guys explain to me what im doing wrong?
Private Sub CommandButton1_Click()
Dim label_start As Label
label_start:
Dim objIE As Object: Set objIE = CreateObject("Internetexplorer.application")
objIE.Top = 0
objIE.Left = 0
objIE.Width = 800
objIE.Height = 600
objIE.Visible = False
On Error Resume Next
objIE.Navigate (My link - Cant display this due to forum-rules.)
Do
DoEvents
If Err.Number <> 0 Then
objIE.Quit
Set objIE = Nothing
GoTo label_start:
End If
'Loading the source code
Loop Until objIE.ReadyState = 4 '4 indicates that page is completely loaded
Dim sHtml_YahooFinance As String
sHtml_YahooFinance = objIE.Document.body.innerHTML
'parsing the html string
If InStr(sHtml_YahooFinance, "yfs_pp0_") > 0 Then
sHtml_YahooFinance = Mid(sHtml_YahooFinance, InStr(sHtml_YahooFinance, "yfs_pp0_"), sHtml_YahooFinance) 'I want it to truncate where "yfs_pp0_" is located.
UserForm1.TextBox1.Text = sHtml_YahooFinance 'here im printing in Textbox1 after the source code has been edited, i think...
End If
End Sub
If i look in Textbox1, i see the same result, whether i remove/keep the line where i truncate... Could anybody enlighten me?
Hope you have a good day!
JKB