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 1 5153
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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?...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |