用vb读取一个html文件,去掉标签只显示其中文本内容

来源:百度知道 编辑:UC知道 时间:2024/05/30 11:05:41
用vb读取一个html文件,只显示其中文本内容,小弟刚开始学习vb,语法和算法上都不是太精通,所以向大家求助了.
这个是我写的代码:算法是当读到"<"时给变量a赋值0,当读到">"时给a赋值1,这样就可以用条件if a=1 then text1.text=text1.text+indata 来进行在文本框中的显示,但是不知道是什么地方出了问题,就是读不出来...
高手来指点一下,谢谢了

Open FileName For Input As #1

Do While Not EOF(1)

Input #1, inData

If inData = "<" Then a = 0
End If

If inData = ">" Then a = 1
End If

If a = 1 Then

Text1.Text = Text1.Text & inData
End If

Loop

用webbrower控件

请看下例
’声明:该程序由csdn论坛获得

dim dwinfolder as new shellwindows
dim withevents eventie as webbrowser_v1

private sub command1_click()
dim objie as object

for each objie in dwinfolder
if objie.locationurl = list1.list(list1.listindex) then
set eventie = objie
command1.enabled = false
list1.enabled = false
text1.text = ""
exit for
end if
next
end sub

private sub eventie_navigatecomplete(byval url as string)
text1.text = text1.text + chr(13) + chr(10) + url
end sub