I am trying to load two text files from a dialogbox into a listbox. I noticed in the dialogbox properties there is a place for multiselction but how would i pass both textboxes to an array?

you want to Select the multiple files once and load into list box? using open FileDialog?

yes, and i need to format the out put in the listbox so it looks like

column 1 column 2
---------- ------------
txt file1 txt file2

code so far

Option Stric on 

Dim streamReader As StreamReader

    Try
        Dim openFiles As New OpenFileDialog
        openFiles.Filter = ("Text Files|*.txt")
        openFiles.ShowDialog()
        Dim sr As New IO.StreamReader(openFiles.FileName)
        While (sr.Peek() > -1)
            BoxOfficeListBox.Items.Add(sr.ReadLine)
        End While
        sr.Close()
        sr.Dispose()
    Catch ex As Exception
    End Try
End Sub

I have the openfiledialog set in the properties to use multi select but its not working... Not sure how i would handle the array to except the 2 txt files then display them like i discribed above in the listbox

thank you for your help!

this should help you

 Try
            Dim strlist As New List(Of String)
            Dim file As String
            Dim openFiles As New OpenFileDialog
            openFiles.Multiselect = True
            If openFiles.ShowDialog = DialogResult.OK Then
                For Each file In openFiles.FileNames
                    Dim sr As New IO.StreamReader(openFiles.FileName)
                    While (sr.Peek() > -1)
                        strlist.Add(sr.ReadToEnd)
                    End While

                Next
            End If
            For i As Int16 = 0 To 1
                ListBox1.Items.Add(strlist.Item(i) & vbTab & strlist.Item(i + 1))
            Next
        Catch ex As Exception
        End Try

Note: I am Assuming you have only two files to read

Ah yes only 2 text files. Thank you for the guidance Ill give this a shot.

It allows me to select 2 text files but it loads one of them twice and ignores the other one :\ and its placing them horizontally across the listbox. I looked at the properties and noticed they have a multicolumn option for the list box...

You should select the multicolumn to true.

Yeah its odd because its set to true.. But because we have it set as readtoend it causes it to not be virticle but if I change it to readline then its a virticle list. Even if i select 2 files it reads only one of them twice. When i set a break point i can see it loading both text files in but it just read the one of them 2 times and displays it in the list box the second textfile isnt getting read.

You cant show the complte text file data in list box as columns if data is huge. I loaded simple text files whith above code and worked for me. I dont know what kind of data you have in your text files.

Below is what is in the two textoxes i have.

BoxOffice.txt
425488741
555909803
868659354
966435555
720388023
513445231
617520987
785677477
426826774
666367656
624527272
481005579
405873493
316186616
362876056
271586451
499954330
465588535
504705882
546490272
640803677
586090727

title.txt
Dr. No
From Russia with Love
Goldfinger
Thunderball
You Only Live Twice
On Her Majesty's Secret Service
Diamonds Are Forever
Live and Let Die
The Man with the Golden Gun
The Spy Who Loved Me
Moonraker
For Your Eyes Only
Octopussy
A View to a Kill
The Living Daylights
Licence to Kill
GoldenEye
Tomorrow Never Dies
The World Is Not Enough
Die Another Day
Casino Royale
Quantum of Solace

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.