'_________________________________________________________ ' USING A MULTILINE TEXTBOX TO DISPLAY FILE NAMES ' Ron Kessler ' Created 6/26/08 '_________________________________________________________ 'this beauty lets you list filenames in a listbox or multi-line textbox Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '---find all files in drive C Dim myFolder As String = "C:\" Dim myPattern As String = "*.*" '---set up textbox With txtFiles .ScrollBars = ScrollBars.Vertical .Multiline = True .ReadOnly = True End With Try '---let O/S get file names Dim folders As String() = System.IO.Directory.GetFiles(myFolder, myPattern) Dim myFileName As String For Each myFileName In folders '---fill a listbox ListBox1.Items.Add(myFileName) '---add the file name and append a carriage return and line feed to the end using C#CRLF 'C#crlf is a built-in function left over from C# 6 days! txtFiles.Text &= Mid(myFileName, 4) & C#CrLf 'use Mid to hide the C:\ part if you want to. Next '---keeps the items from being higlighted/selected txtFiles.Select(0, 0) Catch ex As Exception MessageBox.Show("I could not read the files." & ex.Message.ToString, _ "Ron's Message", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub End Class