Link to home
Start Free TrialLog in
Avatar of bob saget
bob saget

asked on

using a file dialog box, then output selected file to listbox

im using a file dialog box to let the user see a list of text files (*.txt) when i select one to open.it wont output it in my listbox im using a do while loop to read each item from the file and print it in upper case in a listbox.
Avatar of Obadiah Christopher
Obadiah Christopher
Flag of India image

A sample code might help identifying the issue.

Is this a windows desktop application?
Avatar of bob saget
bob saget

ASKER

Dim file() As String

        ofdquest1.Filter = "Text.Files|*.txt"

        ofdquest1.FileName = ""

        ofdquest1.ShowDialog()
        Do While ofdquest1.FileName <> ""
            file = IO.File.ReadAllLines(ofdquest1.FileName)
        For i = 0 To file.Count - 1
                lstrelease.Items.Add(file(i))
                If ofdquest1.FileName <> "" Then
                    file = IO.File.ReadAllLines(ofdquest1.FileName)



                Else
                    MessageBox.Show("select a file forst")
                End If

            Next
        Loop

        file.close()




and yes it is.
ASKER CERTIFIED SOLUTION
Avatar of Obadiah Christopher
Obadiah Christopher
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Bob

Are you trying to read text from one file or multiple files into the listbox?