Website Design United States, Website Design California, Website Designing United States, Website Designing California

Use the Dir$ function to show files and folder - Visual Basic 6

A simple example of how to use the Dir$() function to return files and folders on your hard drive (or on a mapped network drive)

Option Explicit

Private Sub cmdExit_Click()
Unload Me '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
End Sub

Private Sub cmdShow_Click()
Dim sFile As String

Cls 'Clear the screen
Font.Bold = True 'Bold font
Print "Files located on C:\" 'Show header
Font.Bold = False 'Turn off bold font
sFile = Dir$("C:\", vbNormal) 'Get first entry
Do Until Len(sFile) = 0 'Loop until we run out (sFile will be empty)
Print " " & sFile 'Display what we found
sFile = Dir$ 'Get next entry
Loop
End Sub

Private Sub cmdShowDir_Click()
Dim sFile As String

Cls 'Clear the screen
Font.Bold = True 'Bold font
Print "Directories located on C:\" 'Show header
Font.Bold = False 'Turn off bold font
sFile = Dir$("C:\", vbDirectory) 'Get first entry
Do Until Len(sFile) = 0 'Loop until we run out (sFile will be empty)
If Not sFile = "." And Not sFile = ".." Then 'If in a subdirectory, ignore the encompassing directories
If (GetAttr("C:\" & sFile) And vbDirectory) = vbDirectory Then '
Print " " & sFile 'Display what we found
End If
End If
sFile = Dir$ 'Get next entry.
Loop
End Sub

 

WEB DESIGN INDIA
42 B Malviya Nagar , New Delhi-110017

Skype: manmeetsi
Email: support.webdesignindia@gmail.com
Tel: 91-011-40502005, 9810067295

 















 


© 2008-2009 dotnet4all.com