當前位置:股票大全官網 - 股票行情 - vb 獲取股票行情報價

vb 獲取股票行情報價

這是頁面內容采集問題,沒啥難度

網上代碼太多了(妳可以搜 VB 抓取網頁),以實現基本功能(把頁面 http://www....)的內容抓過來

有了內容,妳需要做的僅是截取部分有用內容後在使用正則表達式篩選即可

比如妳抓過來的內容是截取部分有用內容後放到了字符串 str

那麽使用下面的函數即可

' 正則求值

Public Function Value(ByVal str As String, ByVal RegexEx As String, ByVal SN As Integer) As String

Try

Dim regex As New Regex(RegexEx)

Dim m As MatchCollection = regex.Matches(str)

Try

Return m(SN).ToString()

Catch

Return ""

End Try

Catch

Return ""

End Try

End Function

妳的text1可能是

需要過濾下

dim a as string = Value(str,"...",0).replace("<a>","")

text1.text = a

dim b as string = Value(str,"...",1).replace("<a>","")

text1.text = b

...

順便說下,看股票的話免費軟件壹大把,人家比妳這個功能更強了,而且更新速度比這個網站更快