Populating a User Form Text Box with Array Contents

TheShaunMichael

Board Regular
Joined
Oct 24, 2009
Messages
57
Hi All,

Need to amend the following code so that 1) my array items are separated by commas and 2) they populate a user form text box titled "tbDocumentName." Thank you!

Shaun
Code:
    With Application.FileDialog(msoFileDialogFolderPicker)
        .InitialFileName = Application.DefaultFilePath & "\"
        .Title = "Please select a folder to list Files from"
        .InitialFileName = InitialFoldr$
        .Show
        If .SelectedItems.Count <> 0 Then
            xDirect$ = .SelectedItems(1) & "\"
            xFname$ = Dir(xDirect$)
            ReDim FileList(0)
            i = 0
            Do While xFname$ <> ""
                xFname$ = Dir
                FileList(i) = xFname$
                i = i + 1
                ReDim Preserve FileList(i)
            Loop
        End If
    End With
    
    Me.tbDocumentName.Value = FileList
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
This will fix the array:

From: ReDim Preserve FileList(i)

To: ReDim Preserve FileList(0 To i)
 
Upvote 0
You could try this, but I am not sure that text box will take the List property. Nothing like trying.

Me.tbDocumentName.List = FileList
 
Upvote 0
P.S. Be sure your text box is set to multiline.
 
Upvote 0

Forum statistics

Threads
1,215,373
Messages
6,124,544
Members
449,169
Latest member
mm424

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top