Hi,
I found some code in vb that someone put in a form which populates a listbox using a function for the rowsource. It is using the dir(path,vbdirectory) command. Is there any way to get this to come out in descending sequence? It doesn't look like there is any other parameters. Also, I see logic in there parsing a field called CODE. What is the makeup of this string ? What does it do ?
Any help at all would be appreciated.
Thanks
Here is the function.
' Purpose: To read the contents of a directory into a ListBox.
' Usage: Create a ListBox. Set its RowSourceType to "DirListBox"
' Parameters: The arguments are provided by Access itself.
' Notes: You could read a FileSpec from an underlying form.
' Error handling not shown. More than 512 files not handled.
Static StrFolders(0 To 511) As String
Dim StrPath As String
Dim StrDirName As String
StrPath = "U:\CompanyDocuments\Circulars\Fine Fare\"
'StrPath = "C:\"
StrDirName = Dir(StrPath, vbDirectory)
Select Case code
Case 0 ' Initialize
DirFineFareFolders = True
Case 1 ' Open: load file names into array
DirFineFareFolders = Timer
IntCount = 0 ' Add this to reset so doesn't duplicate file list.
Do While Len(StrDirName) > 0
If GetAttr(StrPath & StrDirName) = vbDirectory Then
If StrDirName <> "." And StrDirName <> ".." Then
StrFolders(IntCount) = StrDirName
IntCount = IntCount + 1
End If
'IntCount = IntCount + 1
End If
StrDirName = Dir
Loop
Case 3 ' Rows
DirFineFareFolders = IntCount
Case 4 ' Columns
DirFineFareFolders = 1
Case 5 ' Column width in twips
DirFineFareFolders = 1440
Case 6 ' Supply data
DirFineFareFolders = StrFolders(row)
Case 9 ' End
End Select
Remember when... everything worked and there was a reason for it?
I found some code in vb that someone put in a form which populates a listbox using a function for the rowsource. It is using the dir(path,vbdirectory) command. Is there any way to get this to come out in descending sequence? It doesn't look like there is any other parameters. Also, I see logic in there parsing a field called CODE. What is the makeup of this string ? What does it do ?
Any help at all would be appreciated.
Thanks
Here is the function.
' Purpose: To read the contents of a directory into a ListBox.
' Usage: Create a ListBox. Set its RowSourceType to "DirListBox"
' Parameters: The arguments are provided by Access itself.
' Notes: You could read a FileSpec from an underlying form.
' Error handling not shown. More than 512 files not handled.
Static StrFolders(0 To 511) As String
Dim StrPath As String
Dim StrDirName As String
StrPath = "U:\CompanyDocuments\Circulars\Fine Fare\"
'StrPath = "C:\"
StrDirName = Dir(StrPath, vbDirectory)
Select Case code
Case 0 ' Initialize
DirFineFareFolders = True
Case 1 ' Open: load file names into array
DirFineFareFolders = Timer
IntCount = 0 ' Add this to reset so doesn't duplicate file list.
Do While Len(StrDirName) > 0
If GetAttr(StrPath & StrDirName) = vbDirectory Then
If StrDirName <> "." And StrDirName <> ".." Then
StrFolders(IntCount) = StrDirName
IntCount = IntCount + 1
End If
'IntCount = IntCount + 1
End If
StrDirName = Dir
Loop
Case 3 ' Rows
DirFineFareFolders = IntCount
Case 4 ' Columns
DirFineFareFolders = 1
Case 5 ' Column width in twips
DirFineFareFolders = 1440
Case 6 ' Supply data
DirFineFareFolders = StrFolders(row)
Case 9 ' End
End Select
Remember when... everything worked and there was a reason for it?