Results 1 to 2 of 2

Thread: Urgent Help Pleaseeeeeeeee.......

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2002
    Posts
    2

    Urgent Help Pleaseeeeeeeee.......

    Hi guys,

    any help would be appreciated,

    it is very urgent problem I have.

    I have the following file names (they r dummy -but in live environment they would be something like this - all I want is I have to retreive the latest File from the existing ones

    my data looks something like this

    sample data:
    ---------------------
    1) TEST_201220020926.txt
    TEST_201220020927.txt
    TEST_221220021015.txt

    2) ABC_201220020926.txt
    ABC_201220020927.txt
    ABC_251220021012.txt

    (after undescore its a date & time combination)

    but I dont know the sort order of these files in real time environment -how can i do it???????

    it can be any combination of date& time how do I get the latest file based on each combination provided?????

    and my problem is that I have to pick up the latest file out of each combination in the sense that I have to retreive ony
    ( TEST_221220021015.txt & ABC_251220021012.txt) files
    out of all the files.

    please guys someone help me- its very urgent.

    Thanks in advance


    Regards.

    Gandhi

  2. #2
    Fanatic Member
    Join Date
    Nov 2001
    Location
    Bangkok
    Posts
    969

    Hi

    You create a FileListBox (You need maybe to add in the Components the FileListBox)

    The code is not perfect written, because I am lazy, but it works.

    Add this code:


    Private Sub Command1_Click()
    Dim strFilename As String

    strFilename = DateCompare("TEST")
    MsgBox "The latest File = " & strFilename

    strFilename = DateCompare("ABC")
    MsgBox "The latest File = " & strFilename

    End Sub

    Private Function DateCompare(strFilename As String)

    File1.FileName = App.Path & "\" & strFilename & "*.txt"
    File1.Refresh

    datCompare = Format(CDate("01.01.1980"), "yyyymmdd")

    numDelimiter = InStr(1, File1.List(0), "_") + 1
    numHighestDate = -1

    For i = 0 To File1.ListCount - 1
    strDat = Mid(File1.List(i), numDelimiter, 8)
    strDat = CDate(Left(strDat, 2) & "." & Mid(strDat, 3, 2) & "." & Mid(strDat, 5, 4))
    strDat = Format(strDat, "yyyymmdd")
    If strDat > datCompare Then
    datCompare = strDat
    numHighestDate = i
    End If
    Next



    DateCompare = File1.List(numHighestDate)

    End Function




    have fun with it
    nice greetings
    Franky
    Last edited by Franky; Dec 7th, 2002 at 11:34 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width