473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Callback function to populate listbox with filelist

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
Nov 13 '05 #1
1 5157
Grant Hammond wrote:
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
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Marian Aldenhövel | last post by:
Hi, I am using the FMOD audio-library with the pyFMOD python bindings. pyFMOD uses ctypes. It is possible to register callback functions with FMOD that are called at certain points in the...
3
by: ThinkRS232 | last post by:
I have a Win32 DLL that has a standard _stdcall (WINAPI) exports. I am able to call these fine from C#. One call in particular however has a callback to a CDECL function. How would I set that up?...
11
by: The Frog | last post by:
Hi all, Maybe I am just missing something simple here, but I seem to have an issue with a callback function in A97 that is used to fill a Listbox with values. The first time the callback...
6
by: smmk25 | last post by:
Before I state the problem, I just want to let the readers know, I am knew to C++\CLI and interop so please forgive any newbie questions. I have a huge C library which I want to be able to use in...
2
by: Pradeep | last post by:
Hi all, Can any one explain me what is callback function.... I have written some code after reading some tutorials from internet... But I am not sure is it a right way to write a call back...
1
by: Chaihana Joe | last post by:
Hi I'm trying to populate a listbox as a value list in code (access 2003). Unfortunately I'm getting 'runtime error 2176 - the setting for this property is too long' somewhere around the 2000...
6
by: jmDesktop | last post by:
In a function that takes another function (function pointer) as a argument, or the callback function, which is the one that "calls back"? I'm having a hard time understanding the language. Am I...
4
by: George Allen | last post by:
I have been experimenting wiht using the Listbox Callback function to solve an issue I have with my db tool. The function below connects ADO to a SQL server database and table and reads those...
8
by: George Allen | last post by:
So, I have two comboboxes on my form. One has a vlaue list (A), then other uses a callback function to populate (B) items based on the combo A selection. If I select something in A, then the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.