+ Reply to Thread
Results 1 to 5 of 5

ListBox date format

Hybrid View

  1. #1
    Registered User
    Join Date
    10-02-2006
    Posts
    6

    ListBox date format

    I have a listbox on a userform that returns a multicolom list of results including a date. The date is formatted on the worksheet as yyyy.mm.dd when the date is entered from a calender control it enters properly. My problem is when the search is done, the date is returned in the listbox as d/m/yy. Is there a way of formatting the date in the listbox to display as yyyy.mm.dd.

    thanks

  2. #2
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127
    Can you post the code you used, or preferably, a .zip copy of the workbook?

  3. #3
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Its done like this:
    Range("A1").Value = Format(Me.ListBox1.Value, "yyyy.mm.dd")
    Not all forums are the same - seek and you shall find

  4. #4
    Registered User
    Join Date
    10-02-2006
    Posts
    6
    Here is the code for the listbox results:

    Private Sub lboResults_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    Dim intItem As Integer
    
    For intItem = 0 To Me.lboResults.ListCount - 1
        If Me.lboResults.Selected(intItem) = True Then
            With Me
                .txtRow.Value = Me.lboResults.List(intItem, 0)
                .txtName.Value = Me.lboResults.List(intItem, 1)
                .txtContact.Value = Me.lboResults.List(intItem, 2)
                .txtDescription.Value = Me.lboResults.List(intItem, 3)
                .txtProperty.Value = Me.lboResults.List(intItem, 4)
                .TxtDate.Value = Me.lboResults.List(intItem, 5)
                .txtPowercase.Value = Me.lboResults.List(intItem, 6)
                If Me.lboResults.List(intItem, 7) = "Yes" Then
                    .chkElectronic.Value = True
                Else
                    .chkElectronic.Value = False
                End If
                .txtDisclosure.Value = Me.lboResults.List(intItem, 8)
                .cmbOK.Enabled = False
                .cmbDelete.Enabled = True
                .cmbAmend.Enabled = False
                
            End With
            Exit Sub
         End If
    Next intItem
    
    End Sub

  5. #5
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Ideally i need your workbook but try replacing this line:
    .TxtDate.Value = Me.lboResults.List(intItem, 5)
    With:
    .TxtDate.Value = Format(Me.lboResults.List(intItem, 5), "yyyy.mm.dd")

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1