Dim t As System.Threading.Thread Private Sub OpenIdFileTextToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenIdFileTextToolStripMenuItem.Click CheckForIllegalCrossThreadCalls = False ServicePointManager.DefaultConnectionLimit = Integer.MaxValue t = New Thread(AddressOf ob_en) t.IsBackground = True t.SetApartmentState(ApartmentState.STA) t.Start() End Sub
Public Sub ob_en() Dim s As New OpenFileDialog s.Filter = "text | *.txt" s.Title = "import Combolist" s.ShowDialog() Dim allLines() As String = System.IO.File.ReadAllLines(s.FileName) ListBox1.Items.AddRange(allLines) End Sub