VB读取网页中TXT ,急急????????????

来源:百度知道 编辑:UC知道 时间:2024/06/02 08:38:32
比如按command2将http://sg.qq.com/sg2007/news/player.txt第一行写入text1.text
请问怎么写???
谢谢

记得将text1的multiline属性设为true
还要添加一个webbrowser1控件
Function getWebContent(browser As WebBrowser) As String
Dim doc As Object
Dim i As Object
Dim strHtml As String

Set doc = browser.Document
For Each i In doc.All
strHtml = strHtml & Chr(13) & i.innerText
Next
getWebContent = strHtml
End Function

Private Sub Command2_Click()
Text1.Text = getWebContent(WebBrowser1)
End Sub

Private Sub Form_Load()
WebBrowser1.Navigate "http://sg.qq.com/sg2007/news/player.txt"
End Sub

1、楼上的正解,只用加个控件就行了,下载到本地后再来读取。

2、或者用xmlhttp对象来直接远程读取。