• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 46
  • Last Modified:

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.
bob saget
bob saget
  • 2
1 Solution
Obadiah ChristopherCommented:
A sample code might help identifying the issue.

Is this a windows desktop application?
bob sagetAuthor Commented:
Dim file() As String

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

        ofdquest1.FileName = ""

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

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



and yes it is.
Obadiah ChristopherCommented:
Have you tried to print this value in say a textbox?

file = IO.File.ReadAllLines(ofdquest1.FileName)

I am guessing it isn't able to read the filepath.

If you are indeed getting the value in the file variable, try to omit these lines and see what happens.

 If ofdquest1.FileName <> "" Then
                    file = IO.File.ReadAllLines(ofdquest1.FileName)
NorieVBA ExpertCommented:

Are you trying to read text from one file or multiple files into the listbox?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now