Example - Dir Function

  1. '===============================================================

    ' Example of using the Dir Function

    ' This script displays all the files In the specified directory.

    ' Files will be displayed one at a time inside message boxes.

    '===============================================================

    Sub Main

    1. Dim filename As String

      Dim dirname As String

      dirname = InputBox("Please type a directory's pathway (be sure to include the ending backslash):","Directory")

      filename = Dir(dirname & "*.*",0)

      Dim count As Integer

      count = 0

      While filename <> ""

      1. count = count +1

        MsgBox count & " - " & filename

        filename = Dir ' find the Next file

      Wend

    End Sub