Refresh Method Example 1

The example uses the Refresh method to update a file list box as test files are being created.  To try this example, paste the code into the Declarations section of a form with a file list box named File1.  Then press F5 and click the form.

Sub Form_Click ()
  Dim FName, I, Msg                      ' Declare variables.
  File1.Pattern = "TestFile.*"           ' Set file pattern.
  For I = 1 To 8                         ' Do 8 times.
    FName = "TESTFILE." & I
    Open FName For Output As FreeFile    ' Create empty file.
    File1.Refresh                        ' Refresh file list box.
    Close                                ' Close file.
  Next I
  Msg = "Choose OK to remove the created test files."
  MsgBox Msg                             ' Display message.
  Kill "TESTFILE.*"                      ' Remove test files.
  File1.Refresh                          ' Update file list box.
End Sub