dbTalk Databases Forums  

Callback function to populate listbox with filelist

comp.databases.ms-access comp.databases.ms-access


Discuss Callback function to populate listbox with filelist in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Grant Hammond
 
Posts: n/a

Default Callback function to populate listbox with filelist - 11-30-2004 , 09:59 PM






I have a callback function that populates a listbox with a list of
file names in a folder. This code came from Terry Kreft/Dev Ashish
some years ago.

I now want to add another column to the list box to display the date
of the file.

I have started modifing the code to handle a 2 coulmn array, but it
dosnt look like I can just change the variable to an array.
Here is the code with my hichlights where I started changing it to an
array with the seconf column to hold the date.

--------------------code------------------
Function fListFill(ctl As Control, varID As Variant, lngRow As Long, _
lngCol As Long, intCode As Integer) As Variant

Static sastFiles() As String
Static slngCount As Long
Static sloclDir As mdl_ListFiles_clsDir
Dim i As Long
'Dim varRet As Variant
Dim varRet() As Variant <--- changed
Dim X As Long

Select Case intCode
Case acLBInitialize
Set sloclDir = New mdl_ListFiles_clsDir
If Not mstFilePath = vbNullString _
Then
With sloclDir
.FillFiles mstFilePath

slngCount = .GetFileCount

If slngCount > 0 Then
'ReDim sastFiles(0 To slngCount-1)
ReDim varRet(0 To slngCount - 1, 2)
<--changed
ReDim sastFiles(0 To slngCount - 1, 2)
<--added
For i = 1 To slngCount
'sastFiles(i - 1) = .NameOfFile(i)
sastFiles(i - 1, 1) = .NameOfFile(i)
<--changed
sastFiles(i - 1, 2) = .DateOfFile(i)
<--added
***not sure if this is valid
expression***
Next i
PDF_accSortStringArray sastFiles()
End If
End With
Else
slngCount = 0
End If
varRet = True **** cant set this if its an array*****

Case acLBOpen
varRet = Timer

Case acLBGetRowCount
varRet = slngCount

Case acLBGetValue
If slngCount > 0 Then
'varRet = sastFiles(lngRow)
varRet(lngRow, 1) = sastFiles(lngRow, 1) <--changed
varRet(lngRow, 2) = sastFiles(lngRow, 2) <--added
Else
'varRet = vbNullString
varRet(lngRow, 1) = vbNullString <--changed
varRet(lngRow, 2) = vbNullString <--added
End If

Case acLBEnd
Set sloclDir = Nothing
Erase sastFiles
End Select
fListFill = varRet

End Function
----------end code----------------

Any suggestions how to get the date of the file and populate the
listbox???


Thanks in advance

Cheers

Grant

Reply With Quote
  #2  
Old   
Trevor Best
 
Posts: n/a

Default Re: Callback function to populate listbox with filelist - 12-01-2004 , 02:18 AM






Grant Hammond wrote:
Quote:
I have a callback function that populates a listbox with a list of
file names in a folder. This code came from Terry Kreft/Dev Ashish
some years ago.

I now want to add another column to the list box to display the date
of the file.

I have started modifing the code to handle a 2 coulmn array, but it
dosnt look like I can just change the variable to an array.
Here is the code with my hichlights where I started changing it to an
array with the seconf column to hold the date.

--------------------code------------------
Function fListFill(ctl As Control, varID As Variant, lngRow As Long, _
lngCol As Long, intCode As Integer) As Variant

Static sastFiles() As String
Static slngCount As Long
Static sloclDir As mdl_ListFiles_clsDir
Dim i As Long
'Dim varRet As Variant
Dim varRet() As Variant <--- changed
Dim X As Long

Select Case intCode
Case acLBInitialize
Set sloclDir = New mdl_ListFiles_clsDir
If Not mstFilePath = vbNullString _
Then
With sloclDir
.FillFiles mstFilePath

slngCount = .GetFileCount

If slngCount > 0 Then
'ReDim sastFiles(0 To slngCount-1)
ReDim varRet(0 To slngCount - 1, 2)
--changed
ReDim sastFiles(0 To slngCount - 1, 2)
--added
For i = 1 To slngCount
'sastFiles(i - 1) = .NameOfFile(i)
sastFiles(i - 1, 1) = .NameOfFile(i)
--changed
sastFiles(i - 1, 2) = .DateOfFile(i)
--added
***not sure if this is valid
expression***
Next i
PDF_accSortStringArray sastFiles()
End If
End With
Else
slngCount = 0
End If
varRet = True **** cant set this if its an array*****

Case acLBOpen
varRet = Timer

Case acLBGetRowCount
varRet = slngCount

Case acLBGetValue
If slngCount > 0 Then
'varRet = sastFiles(lngRow)
varRet(lngRow, 1) = sastFiles(lngRow, 1) <--changed
varRet(lngRow, 2) = sastFiles(lngRow, 2) <--added
Else
'varRet = vbNullString
varRet(lngRow, 1) = vbNullString <--changed
varRet(lngRow, 2) = vbNullString <--added
End If

Case acLBEnd
Set sloclDir = Nothing
Erase sastFiles
End Select
fListFill = varRet

End Function
----------end code----------------

Any suggestions how to get the date of the file and populate the
listbox???

You don't need varRet as an array, just use:

varRet = sastFiles(lngRow, lngCol)

lngCol is one of the parameters to ask for a specific column in the
listbox/combobox, these are normally zero based so consider using
sastFiles(x,0 to 1) instead of sastFiles(x,1 to 2)

--
This sig left intentionally blank


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.