what im trying to do is load a list into a listbox..the dialog works fine, i can search for a .txt file i want but after i open it, it doesn't load into my listbox here is my open button code Code (Text): Private Sub openbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click OpenFileDialog1.Title = "open" OpenFileDialog1.Filter = "Text Documents (*.txt)|*.txt|All Files (*.*)|*.*" OpenFileDialog1.FileName = "" OpenFileDialog1.FilterIndex = 0 OpenFileDialog1.InitialDirectory = "MyDocuments" OpenFileDialog1.CheckFileExists = True OpenFileDialog1.CheckPathExists = True If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then ListBox1.Items.Contains(OpenFileDialog1.FileName) End If End Sub anyone have an idea why its not working?
Are you using the common dialog component? Watch theese > http://sean.cruels.net/vb/31/31.htm http://sean.cruels.net/vb/32/32.htm http://sean.cruels.net/vb/33/33.htm ~Oddworth
Re: Help needed with loading a text file into a listbox (VB. Code (Text): Private Sub openbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click OpenFileDialog1.Title = "open" OpenFileDialog1.Filter = "Text Documents (*.txt)|*.txt|All Files (*.*)|*.*" OpenFileDialog1.FileName = "" OpenFileDialog1.FilterIndex = 0 OpenFileDialog1.InitialDirectory = "MyDocuments" OpenFileDialog1.CheckFileExists = True OpenFileDialog1.CheckPathExists = True If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then Dim aline As String Dim oRead As System.IO.StreamReader oRead = File.OpenText(OpenFileDialog1.FileName) While oRead.Peek <> -1 aline = oRead.ReadLine() listbox1.Items.Add(aline) End While Else MsgBox("Error Loading File") End If End Sub try that oh and you've imported System.IO right?