Dir Function
νΉμ νμΌ λλ λλ ν 리μ μ΄λ¦μ΄λ μ§μ ν κ²μ κ²½λ‘μ μΌμΉνλ λλΌμ΄λΈ λλ λλ ν 리μ μλ λͺ¨λ νμΌκ³Ό λλ ν 리μ μ΄λ¦μ ꡬν©λλ€.
ꡬ문:
Dir [(Text As String) [, Attrib As Integer]]
λ°ν κ°:
String
λ§€κ° λ³μ:
Text: κ²μ κ²½λ‘, λλ ν 리 λλ νμΌμ μ§μ νλ μμμ λ¬Έμμ΄ μμ λλ€. μ΄ μΈμλ Dir ν¨μλ₯Ό μ²μ νΈμΆν λλ§ μ§μ ν μ μμ΅λλ€. νμνλ©΄ κ²½λ‘λ₯Ό URL νκΈ°λ²μΌλ‘ μ λ ₯ν μ μμ΅λλ€.
Attrib: λΉνΈ λ¨μμ νμΌ μμ±μ μ§μ νλ μμμ μ μ μμ λλ€. Dir ν¨μλ μ§μ ν μμ±κ³Ό μΌμΉνλ νμΌ λλ λλ ν λ¦¬λ§ νμν©λλ€. μμ± κ°μ μΆκ°νμ¬ μ¬λ¬ μμ±μ κ²°ν©ν μ μμ΅λλ€.
0 : μΌλ° νμΌμ λλ€.
16 : λλ ν 리μ μ΄λ¦λ§ ꡬν©λλ€.
μ΄ μμ±μ μ¬μ©νμ¬ νμΌ λλ λλ ν λ¦¬κ° μ‘΄μ¬νλμ§ κ²μ¬νκ±°λ νΉμ λλ ν 리μ μλ λͺ¨λ νμΌκ³Ό ν΄λλ₯Ό νμΈν©λλ€.
νμΌμ΄ μ‘΄μ¬νλμ§ νμΈνλ €λ©΄ ν΄λΉ νμΌμ μ 체 κ²½λ‘μ μ΄λ¦μ μ λ ₯ν©λλ€. νμΌ λλ λλ ν 리 μ΄λ¦μ΄ μ‘΄μ¬νμ§ μμ κ²½μ° Dir ν¨μλ λΉ λ¬Έμμ΄("")μ ꡬν©λλ€.
To generate a list of all existing files in a specific directory, proceed as follows: The first time you call the Dir function, specify the complete search path for the files, for example, "D:\Files\*.ods". If the path is correct and the search finds at least one file, the Dir function returns the name of the first file that matches the search path. To return additional file names that match the path, call Dir again, but with no arguments.
To return directories only, use the attribute parameter. The same applies if you want to determine the name of a volume (for example, a hard drive partition).
μ:
Sub ExampleDir
REM Displays all files and directories
Dim sPath As String
Dim sDir As String, sValue As String
sDir="Directories:"
sPath = CurDir
sValue = Dir$(sPath + getPathSeparator + "*",16)
Do
If sValue <> "." And sValue <> ".." Then
If (GetAttr( sPath + getPathSeparator + sValue) And 16) >0 Then
REM get the directories
sDir = sDir & chr(13) & sValue
End If
End If
sValue = Dir$
Loop Until sValue = ""
MsgBox sDir,0,sPath
End Sub