1

I am a novice at coding and whilst I have found examples on Stackoverflow that ought to address my situation, I struggle to understand the syntax and hence convert the example to my needs.

So I have a folder containing Outlook MSG files which I want process in 'Sent date' order. So what I'm trying to do is load them into a list and then sort them by date.

This may be a daft way to do it but I figured that if I create a 'class' containing filename and the date of each message, I could: add these to a list, sort it and then process the list.

So my class looks like this:

Class sMSG
    Public sFilename As String
    Public mDate As Date
End Class

My code to sort the list (modified from a stackoverflow example), looks like this:

            Dim ordered = From obj In SortedList
            OrderBy(obj.mdate Ascending)
            SortedList = ordered.ToList()

It generates the error: BC32017: Comma, ')', or a valid expression continuation expected.

I'm not familiar with this style of coding and can't work out where I am going wrong.

Any help would be appreciated but please be explain it in terms that a complete moron would understand as that just about sums me up at the moment!

1
  • Please give us a link to the example you mention. We may be able to give a better answer with that information. Commented Nov 26, 2021 at 12:52

1 Answer 1

3
        SortedList = (From obj In SortedList Select obj Order By obj.mDate Ascending).ToList()
    'or
    SortedList = SortedList.OrderBy(Function(d) d.mDate)
Sign up to request clarification or add additional context in comments.

2 Comments

Many thanks Wojciech, not only does that work but it's also very elegant :-)
@MaxHeadroom Please accept the answer by clicking the check mark (tick mark) to the left of the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.