ListView sorting VB4.0

There is a problem with sorting a listview by a date in VB 4.0.  Does anyone know a way to get around the problem or is it best to create a public function that will manually sort them?

(The problem with sorting by date is it seems to be sorting by the text value of the date.  If it is mm/dd/yyyy they will be sorted by position 1)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Put a picturebox picColor on the form and set the following properties:


Then call the following sub:

SetColorbar lstView, picColor

(where lstView is the name of your listview control)

Note: lstView style has to be set to lvwReport!

Public Sub SetColorBar(cListView As ListView, _
                       cColorBar As PictureBox, _
                       Optional lFirstColor As Long = &HE2F1E3, _
                       Optional lSecondColor As Long = vbWindowBackground)

    Dim iLineHeight As Long
    Dim iBarHeight As Long
    Dim lBarWidth As Long
    On Error GoTo SetColorBarError
    If Not cListView.View = lvwReport Then GoTo SetColorBarError
    cListView.PictureAlignment = lvwTile
    cColorBar.Font = cListView.Font
    iLineHeight = cColorBar.TextHeight("|") + Screen.TwipsPerPixelY
    'iBarHeight = iLineHeight * 3
    iBarHeight = iLineHeight * 1
    lBarWidth = cListView.Width
    cColorBar.Height = iBarHeight * 2
    cColorBar.Width = lBarWidth
    cColorBar.Line (0, 0)-(lBarWidth, iBarHeight), lFirstColor, BF
    cColorBar.Line (0, iBarHeight)-(lBarWidth, iBarHeight * 2), lSecondColor, BF
    cListView.Picture = cColorBar.Image
    Exit Sub

    cListView.Picture = LoadPicture()
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It seems that the same thing exists with VB6, I would say you will have to use some sort of function to sort date and then use listview.additem.

If you are getting the values using an SQL query then to sort the values first should be easy.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.