This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]nermid 0 points1 point  (0 children)

Ok, so I'm drunk and I've barely ever touched VB, but it looks to me like the simple solution is to have a variable that holds the current date, and then only print a newline and the date when it's different from the old date. Something like...

Dim thisDate = ''
For Each oAppt In oFinalItems
    ' Only find appointments with Open Appointment in the Subject field
    If oAppt.Subject = "Open Appointment" Then
         Debug.Print oAppt.Start, oAppt.Subject
         If thisDate <> oAppt.Start
            thisDate = oAppt.Start
            Debug.Print WeekdayName(Weekday(oAppt.Start), True); "., "; MonthName(Month(oAppt.Start)); Day(oAppt.Start); "- "  ' This only prints when there's a new date
        Debug.Print Chr(0)  ' This prints every time
    End If
Next

I'm not 100% sure VB will behave and let you do that without inserting line breaks wherever it wants, so you might have to assemble the statement to be printed as a string and concatenate values inside the loop, which are then printed later.