473,394 Members | 1,761 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,394 software developers and data experts.

Determining whether I need a multi-dimension array

pob
I was all happy because thru some tutelage of others I created this
array to find the newest file in a directory. However, I then
realized its great that I now know the latest file, but I need to know
the name of the file. Unfortunately, I am only passing the date into
the array.

Do I need to create a m-d array ? If so how do I create a 2-d array
where I do not know how many rows I will be looping thru ?
Function fileageck() As Boolean()

Dim myfilename As String
Dim myfilepath As String
Dim strD As String
Dim strT As String
Dim datDT As Date
Dim i As Integer
Dim sngarray() As Date 'array to store filenames

myfilepath = "F:\test\"
myfilename = Dir(myfilepath & "test*.txt", vbHidden)

Do Until myfilename = ""
ReDim Preserve sngarray(i)
strD = Mid(myfilename, 5, 8)
strT = Mid(myfilename, 13, 4)
datDT = DateSerial(CInt(Mid(strD, 3, 2)) + 2000, Mid(strD, 5, 2),
Right(strD, 2)) + TimeSerial(CInt(Left(strT, 2)), CInt(Mid(strT, 3,
2)), CInt(Right(strT, 2)))
sngarray(i) = datDT
myfilename = Dir
i = i + 1
Loop

For i = 0 To UBound(sngarray)
myfilename = sngarray(i)
If i 0 Then
If myfilename sngarray(i - 1) Then
'File being tested is the newest so this file is the winner until
the next loop
Else
myfilename = sngarray(i - 1)
End If
Else
End If
Next i

End Function

Jan 31 '07 #1
2 2062
On 30 Jan 2007 20:46:23 -0800, "pob" <po*******@gmail.comwrote:

Rather than sngArray (btw, a bad variable name; sng means "single" for
most people), use a UDT = user defined type:
In a module, declare (off the top of my head)
type MyFileData
strFilename as String
dtFileDate as Date
end type

Then declare your array:
dim aryFiles() as MyFileData

and in your loop, set the values:
aryFiles(i).strFilename = myFilename
aryFiles(i).dtFileDate = datDT

-Tom.
>I was all happy because thru some tutelage of others I created this
array to find the newest file in a directory. However, I then
realized its great that I now know the latest file, but I need to know
the name of the file. Unfortunately, I am only passing the date into
the array.

Do I need to create a m-d array ? If so how do I create a 2-d array
where I do not know how many rows I will be looping thru ?
Function fileageck() As Boolean()

Dim myfilename As String
Dim myfilepath As String
Dim strD As String
Dim strT As String
Dim datDT As Date
Dim i As Integer
Dim sngarray() As Date 'array to store filenames

myfilepath = "F:\test\"
myfilename = Dir(myfilepath & "test*.txt", vbHidden)

Do Until myfilename = ""
ReDim Preserve sngarray(i)
strD = Mid(myfilename, 5, 8)
strT = Mid(myfilename, 13, 4)
datDT = DateSerial(CInt(Mid(strD, 3, 2)) + 2000, Mid(strD, 5, 2),
Right(strD, 2)) + TimeSerial(CInt(Left(strT, 2)), CInt(Mid(strT, 3,
2)), CInt(Right(strT, 2)))
sngarray(i) = datDT
myfilename = Dir
i = i + 1
Loop

For i = 0 To UBound(sngarray)
myfilename = sngarray(i)
If i 0 Then
If myfilename sngarray(i - 1) Then
'File being tested is the newest so this file is the winner until
the next loop
Else
myfilename = sngarray(i - 1)
End If
Else
End If
Next i

End Function
Jan 31 '07 #2
pob wrote:
I was all happy because thru some tutelage of others I created this
array to find the newest file in a directory. However, I then
I say, have you considered the FoundFiles Object? I use a variation of
this to populate a temporary Jet table in one of my Oracle applications
with image locations so that my splash and "about" form can randomly
display pictures from a specified directory. Looking more closely at
the help on the FoundFiles Object, I also looked up the execute method
applies to the FileSearch object. There is an msoSortByLastModified
expression that might of some use.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me
Jan 31 '07 #3

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

Similar topics

12
by: Cliff Wells | last post by:
Hi, I'm writing an application that needs to know if an Internet connection is available. Basically, I want to have something similar to what a lot of email clients have, where the app can work...
4
by: Keith Patrick | last post by:
I have a web page that has a bunch of usercontrols, each declaring a Button called "GoButton". Now, my parent page has to be able to determine which button triggered the event. The catch is: I'd...
14
by: googler | last post by:
Is there any C library function that returns the size of a given file? Otherwise, is there a way in which file size can be determined in a C program? I need to get this for both Linux and Windows...
4
by: petermichaux | last post by:
Hi, I'm hoping for a reason I'm wrong or an alternate solution... I'd like to be able to dynamically include some javascript files. This is like scriptaculous.js library but their solution is...
4
by: Nathan Sokalski | last post by:
When determining whether a String can be converted to a DateTime, you can use the IsDate() method. However, I would also like to know whether the string is a date, a time, or both a date and a...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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.