WebBrowser 控件将在控件中显示网页,将您限制在一个页面,或者您可以告诉它在单独的窗口中打开页面,这将为每个链接打开一个 Internet Explorer 窗口。我还使用了 File.ReadAllLines 方法来获取链接数组,以便您可以遍历网页。这对我有用,但可能不是你想要的。
Public Class Form1
Dim wb As New WebBrowser
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim filename As String = "C:\temp\links.txt"
Dim links As String() = IO.File.ReadAllLines(filename)
For Each link As String In links
wb.Navigate(link, True)
Next
End Sub
Public Sub New()
InitializeComponent()
Controls.Add(wb)
wb.Dock = DockStyle.Fill
End Sub
End Class
我的名为 Links.txt 的文本文件如下所示:
www.google.com
www.msdn.com
www.bing.com