我想简单地输入股票,点击获取价格按钮,让按钮返回它所刮的价格。
我对Excel VBA有经验,如何抓取但不是如何转换为Visual Studio(VB语言)
以下是我到目前为止所获得的表格。我试图添加HTML文档和Internet控件方法。到目前为止,我可以成功打开和关闭Internet Explorer - 我只是无法让它刮掉任何东西。它只是错误,我不能将Internet Explorer作为HTML对象。以下是到目前为止的代码......
Public Class Form1
Dim stockBox As Single
Dim price As Single
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
End Sub
Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click
End Sub
'Private Function READYSTATE_COMPLETE() As Object
'Throw New NotImplementedException()
' End Function
' Private Sub DoEvents()
'Throw New NotImplementedException()
' End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim ie As Object
Dim px As Single
ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.navigate("http://finance.yahoo.com/q?s=" & (TextBox1.Text))
'Do
' DoEvents
'Loop Until ie.readyState = READYSTATE_COMPLETE
'Dim doc As HtmlDocument
'doc = ie.document
While ie.readyState <> 4
End While
On Error Resume Next
px = ie.GetElementById("yfs_l84_" & (TextBox1.Text)).InnerText
ie.Quit
End With
Label3.Text = px
End Sub
结束班