【发布时间】:2016-07-16 01:36:11
【问题描述】:
我正在尝试使用新线程创建一个新的网络浏览器,但是当我尝试运行该程序时,我总是收到以下错误:
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim curFile1 As String = TextBox4.Text
If (File.Exists(curFile1)) Then
MsgBox("Ok")
Else
MsgBox("Please a User Agent file", MsgBoxStyle.Critical, "Error")
Exit Sub
End If
Dim curFile2 As String = TextBox1.Text
If (File.Exists(curFile2)) Then
MsgBox("Ok")
Else
MsgBox("Please a IP file", MsgBoxStyle.Critical, "Error")
Exit Sub
End If
Try
' Open the file using a stream reader.
Using sr As New StreamReader(curFile2)
' Read the stream to a string and write the string to the console.
ip_text = File.ReadAllLines(curFile2)
End Using
Catch er As Exception
MsgBox("The file could not be read: IP", MsgBoxStyle.Critical, "Error")
Exit Sub
End Try
Try
' Open the file using a stream reader.
Using sr2 As New StreamReader(curFile1)
' Read the stream to a string and write the string to the console.
user_text = File.ReadAllLines(curFile1)
End Using
Catch er As Exception
MsgBox("The file could not be read: User Agent", MsgBoxStyle.Critical, "Error")
Exit Sub
End Try
nr = 0
For Each ip As String In ip_text
MsgBox(ip)
trd = New Thread(AddressOf make_it)
trd.IsBackground = True
trd.Start()
nr = nr + 1
Next
End Sub
Private Sub make_it()
Dim decible = New WebBrowser()
web_panel.Controls.Add(decible)
decible.Name = "browser" & nr
Dim RandomIpAddress As String = user_text(GetRandom(user_text.Length))
MsgBox(RandomIpAddress)
ChangeUserAgent(RandomIpAddress)
decible.Navigate("http://www.whatsmyuseragent.com/")
End Sub
非常感谢您的帮助,现在卡在这个错误上好几天了。
【问题讨论】:
-
错误文本的图像通常不是一个好主意,因为人们会想要对错误文本进行搜索
标签: .net vb.net multithreading visual-studio visual-studio-2010