Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference > Siebel VB Language Reference >
Dir Function
The standard VB function Dir returns a filename that matches the specified pattern, having the specified attributes.
Syntax
Dir[$] [(pathname[, attributes])]
Argument Description pathname A string or string expression evaluating to a path or filename attributes An integer expression specifying the file attributes to selectReturns
The first filename that matches the pathname argument and has the specified attributes. Use the following integer values for attributes to return the specified type of file.
Integer File Type 0 (default) Normal files (no attributes set) 2 Normal and hidden files 4 Normal and system files 8 Volume label (only) 16 Normal files and foldersNOTE: The values in the table can be added together to select multiple attributes. For example, to list hidden and system files in addition to normal files, set attributes to 6 (6 = 2 + 4). If attributes is set to 8, the Dir function returns the volume label of the drive specified in the pathname argument, or of the current drive if a drive is not explicitly specified.
Usage
Pathname can include a drive specification and wildcard characters (? and *). An empty string ("") passed as pathname is interpreted as the current folder (the same as "."). To retrieve additional matching filenames, call the Dir function again, omitting the pathname and attributes arguments. If no file is found, an empty string ("") is returned.
The dollar sign ($) in the function name is optional. If it is included, the return type is string. Otherwise, the function returns a variant of vartype 8 (string).
Example
This example lists the contents of the diskette in drive A.
Sub Button_Click
Dim msgReturn
Dim folder, count
Dim x, msgtext
Dim A()
count = 1ReDim A(100)
folder = Dir ("A:\*.*")
Do While folder <> ""
A(count) = folder
Count = count + 1
folder = Dir
loop
msgtext = "Contents of drive A:\ is:" & Chr(10) & Chr(10)
For x = 1 to count
msgtext = msgtext & A(x) & Chr(10)
Next x
End SubSee Also
ChDir Statement
ChDrive Statement
CurDir Function
MkDir Statement
RmDir Statement
Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference Published: 18 June 2003 |