Example:

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

' 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

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 <> ""

count = count +1

MsgBox count & " - " & filename

filename = Dir ' find the Next file

Wend

End Sub

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

' Bitmap sample using the Dir Function

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

Sub DrawBitmapSample

Dim MyList()

Begin Dialog BitmapDlg 60, 60, 290, 220, "Enable bitmap sample", .DlgFunc

ListBox 10, 10, 80, 180, MyList(), .List1, 2

Picture 100, 10, 180, 180, "Forest.bmp", 0, .Picture1

CancelButton 42, 198, 40, 12

OKButton 90, 198, 40, 12

End Dialog

Dim frame As BitmapDlg

' Show the bitmap dialog

Dialog frame

End Sub

Function DlgFunc( controlID As String, action As Integer, suppValue As Integer )

DlgFunc = 1 ' Keep dialog active

Select Case action

Case 1 ' Initialize

temp = Dir( "c:\Windows\*.bmp" )

count = 0

While temp <> ""

count = count + 1

temp = Dir

Wend

Dim x() As String

ReDim x(count)

x(0) = Dir( "c:\Windows\*.bmp" )

For i = 1 To count

x(i) = dir

Next i

DlgListBoxArray "List1", x()

Case 2 ' Click

fileName = "c:\windows\" & DlgText("List1")

DlgSetPicture "Picture1", fileName

End Select

End Function