Results 1 to 8 of 8
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    .DateModified (VB6)

    With the following code, I have an array of textbox's which show path & filename.

    I wish to change this to show the date the image was put on the system, but not sure of the syntax.
    Can someone help here:

    <pre>'Imaging
    Private Sub FillImages(intIndex As Integer)
    Dim i As Integer

    imgDel
    If intIndex > intFileCount - intNumberOfImages + 1 Then
    intIndex = intFileCount - intNumberOfImages + 1
    End If
    If intIndex < 1 Then
    intIndex = 1
    End If

    For i = 1 To intNumberOfImages
    Me.Controls("img" & i).Picture = LoadPicture(strFolder & "" & arrFileNames(i + intIndex - 1))
    Me.Controls("Text" & i).Text = (strFolder & "" & arrFileNames(i + intIndex - 1))
    Next
    Me.txtInfo = "Images " & intIndex & " to " & (intIndex + intNumberOfImages - 1) & " of " & intFileCount
    intCurIndex = intIndex
    Me.cmdFirst.Enabled = (intIndex > 1)
    Me.cmdPrev.Enabled = (intIndex > 1)
    Me.cmdNext.Enabled = (intIndex < intFileCount - intNumberOfImages + 1)
    Me.cmdLast.Enabled = (intIndex < intFileCount - intNumberOfImages + 1)

    End Sub</pre>


  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: .DateModified (VB6)

    You could add a second column to the arrFileNames array to store the dates you want. What do you mean by "date the image was put on the system"? The last modified date of the file, or is it a date you store in a database, or ...? If it is the created or modified date, you can use FileSystemObject to retrieve this date.

  4. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: .DateModified (VB6)

    Hans
    Ideally, the date the image was sent to the holding folder.
    I'm close but not close enough, variable not defined:

    <pre>'Imaging
    Private Sub FillImages(intIndex As Integer)
    Dim i As Integer
    Dim fso As New Scripting.FileSystemObject
    Dim fil As Scripting.File


    'DoCmd.Hourglass True
    imgDel
    If intIndex > intFileCount - intNumberOfImages + 1 Then
    intIndex = intFileCount - intNumberOfImages + 1
    End If
    If intIndex < 1 Then
    intIndex = 1
    End If

    For i = 1 To intNumberOfImages
    Me.Controls("img" & i).Picture = LoadPicture(strFolder & "" & arrFileNames(i + intIndex - 1))
    Me.Controls("Text" & i).Text = (i + intIndex - 1) & DateLastModified
    'Me.Controls("Text" & i).Text = (strFolder & "" & arrFileNames(i + intIndex - 1))
    Next
    Me.txtInfo = "Images " & intIndex & " to " & (intIndex + intNumberOfImages - 1) & " of " & intFileCount
    intCurIndex = intIndex
    Me.cmdFirst.Enabled = (intIndex > 1)
    Me.cmdPrev.Enabled = (intIndex > 1)
    Me.cmdNext.Enabled = (intIndex < intFileCount - intNumberOfImages + 1)
    Me.cmdLast.Enabled = (intIndex < intFileCount - intNumberOfImages + 1)
    'DoCmd.Hourglass False
    End Sub</pre>


  5. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: .DateModified (VB6)

    If you're trying to retrieve a property, then you need a dot between the object and it's DateLastModified property. Otherwise, the engine is interpreting that as a variable.
    Charlotte

  6. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: .DateModified (VB6)

    Dave,

    It won't work that way. Could you post the code that populates the arrFileNames array? You probably posted it some time last year, but it's better to have the version you currently use.

  7. #6
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: .DateModified (VB6)

    Hans
    I think this is the section:

    <pre>'Imaging
    Private Sub cmdList_Click()

    imgDel
    If Me.txtEst = "" Or Me.txtEst = "*" Then
    MsgBox "You Must Enter A Reference No.", , "Information"
    Me.AcrobatPath = "L:MMPDFESTpdfImageViewer.pdf"
    Me.Pdf1.LoadFile Me.AcrobatPath
    imgDel
    Exit Sub
    End If

    Dim i As Integer
    Dim strFile As String
    ' strLeft5 to find left most 5 characters for frmDetails
    Dim strLeft5 As String
    ' Fixed folder
    strFolder = "L:MMPDFIMAGE"
    FetchPDF
    ' Get Left5
    strLeft5 = Left(Me.txtEst, 5)

    i = 0
    ' Get jpg files in strFolder whose names begin with strLeft5
    strFile = Dir(strFolder & "" & strLeft5 & "*.jpg")

    ' Loop through files
    Do While strFile <> "" And i < 127

    i = i + 1
    arrFileNames(i) = strFile
    strFile = Dir
    Loop
    intFileCount = i

    If intFileCount = 0 Then
    Exit Sub
    End If

    If intFileCount < MaxNumberOfImages Then
    intNumberOfImages = intFileCount
    Else
    intNumberOfImages = MaxNumberOfImages
    End If

    If intNumberOfImages > 0 Then
    FillImages 1
    End If
    End Sub</pre>


  8. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: .DateModified (VB6)

    Dave,

    Modify the declaration of arrFileNames somewhere near the top of the module to

    Private arrFileNames(1 To 127, 1 To 2) As String

    Add the following lines at the beginning of cmdList_Click:

    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")

    and replace the line

    arrFileNames(i) = strFile

    by the following

    arrFileNames(i, 1) = strFile
    arrFileNames(i, 2) = Format(fso.GetFile(strFolder & "" & strFile).DateCreated, "dd/mm/yyyy")

    Modify the code that loads the picture and sets the text as follows:

    Me.Controls("img" & i).Picture = LoadPicture(strFolder & "" & arrFileNames(i + intIndex - 1, 1))
    Me.Controls("Text" & i).Text = arrFileNames(i + intIndex - 1, 2)

    The latter line also occurs in FillTexts, make it look like above.

    Immediately above the End Sub of cmdList_Click, insert a line

    Set fso = Nothing

    Hope this works <img src=/S/crossfingers.gif border=0 alt=crossfingers width=17 height=16>

  9. #8
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: .DateModified (VB6)

    Hans
    As ever, perfect.

    Thanks again

Posting Permissions

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