[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 620
  • Last Modified:

How to calculate the next occurence of Thursday - VB.Net

I have a program that I'm maintaining.

I need to calculate based on today, the upcoming Thursday (not the closest Thursday to today, but the nearest future Thursday).

thanks,
JMO9966
0
JMO9966
Asked:
JMO9966
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
One way...
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Thursday As DateTime = NextThursday()
        MessageBox.Show("The next Thursday is: " & Thursday)
    End Sub

    Private Function NextThursday() As DateTime
        Dim dt As DateTime = DateTime.Today
        While dt.DayOfWeek <> DayOfWeek.Thursday
            dt = dt.AddDays(1)
        End While
        Return dt
    End Function

End Class

Open in new window

0
 
JMO9966Author Commented:
Thanks!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now