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

Is this a windows desktop application?
0
 
bob sagetAuthor Commented:
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.
0
 
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)
1
 
NorieVBA ExpertCommented:
Bob

Are you trying to read text from one file or multiple files into the listbox?
0
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