Dir Function

ড্রাইভ অথবা ডিরেক্টরির উল্লেখিত অনুসন্ধান পাথের সাথে মিলে যায় এমন একটি ফাইল, ডিরেক্টরি অথবা সকল ফাইল এবং ডিরেক্টরি প্রদান করে থাকে।

সিনট্যাক্স:

Dir [(Text As String) [, Attrib As Integer]]

প্রদান মান:

স্ট্রিং

প্যারামিটার:

পাঠ্য: অনুসন্ধান পাথ, ডিরেক্টরি অথবা ফাইল উল্লেখকারী যেকোনো স্ট্রিং এক্সপ্রেশন। শুধুমাত্র প্রথমবার 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).

Error codes:

5 Invalid procedure call

53 File not found 53 File not found

উদাহরণ:

Sub ExampleDir

REM এ সকল ফাইল এবং ডিরেক্টরী প্রদর্শিত হয়

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