Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi select files and pass each file to separate function?

Status
Not open for further replies.

dmoonme

MIS
Jul 21, 2004
33
0
0
US
I need help with this and thanks in advance too :)

I want to multi select files and display the file names into a textbox or RichTextBox and then pass the file paths to a separate function. The function will then do something to each of the files selected. I have the openfiledialog control to work for 1 file that is selected but not for all that's selected.

here's what I have so far:

Code:
Private Sub cmdLoadTextBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLoadTextBox.Click 

Try 

With OpenFileDialog1 

.Filter = "Rick Text File(*.rtf)/*.rtf/" & "Text files (*.txt)/*.txt/" & "Word Doc (*.doc)/*.doc/" & "All files/*.*" 
Me.OpenFileDialog1.Multiselect = True 

If .ShowDialog() = DialogResult.OK Then 
'showDialog method makes the dialog box visible at run time 
FileName = .FileName 

Me.RichTextBox1.Text = OpenFileDialog1.FileName 
myFunc(filename) 
End If 
End With 

Catch es As Exception 
MessageBox.Show(es.Message) 

End Try 
End Sub 

Public Sub MyFunc() 
'do some stuff here with each of the files selected. 
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top