Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8939127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:45:52+00:00 2026-06-15T10:45:52+00:00

If have the following Code: Public Shared Function GetNextWeekDay() As Date Dim value As

  • 0

If have the following Code:

Public Shared Function GetNextWeekDay() As Date
    Dim value As Date = Date.Now
    Do
        value = value.AddDays(1)
    Loop While (value.DayOfWeek = DayOfWeek.Saturday) Or (value.DayOfWeek = DayOfWeek.Sunday)
    Return value
End Function


Public Shared Function DPLoadData() As String
    Dim s As StringBuilder = New StringBuilder("<head><meta http-equiv=""content-type"" content=""text/html;charset=utf-8"" /><META HTTP-EQUIV=""REFRESH"" CONTENT=""900"">")
    s.Append("<style type=""text/css"" media=""all""> body{font-family: Arial;}h4{font-size: 10pt;font-weight: bold;white-space: nowrap;margin-top: 0; margin-bottom: 10px;}")
    s.Append("th{font-size: 9pt;font-weight: normal;text-align: center;white-space: nowrap;}td{font-size: 9pt;}.content td{border: solid 1px #dadada;}")
    s.Append(".content th {border: solid 1px #dadada;background-image: url(""tbl_header_row_bg.gif""); background-repeat: repeat-x; white-space: nowrap;}</style></head>")


  s.Append("<h3>" & "Daily Plan" & "</h3>")
        Dim strCurrDay As String = ""
        s.Append("<h5>" & strCurrDay & "</h5>")



    Dim CurrDateFirstDay As Date = GetNextWeekDay()
    strCurrDay = FormatDateTime(CurrDateFirstDay, DateFormat.LongDate)
    s.Append("<h5>" & strCurrDay & "</h5>")
    s.Append(LoadDataGroupByDate(CurrDateFirstDay))

    Return s.ToString()

End Function

The function DPLoadData generates an HTML file with a table and fills it with bookings. Currently, the HTML file displays the bookings of tomorrow (e.g. if today is Monday, it displays the bookings for Tuesday and if today is Friday, it displays the bookings for Monday).

What i need is that the HMTL file gets generated at 5 p.m. For Example: If today is Monday, then the HTML file should be generated Monday at 5 p.m and should display the bookings for Tuesday until Tuesday 5 p.m and Tuesday at 5 p.m the file should be generated for wednesday and should display the bookings for wednesday until wednesday 5 p.m, and so on.

How can i do that? Please help.

My Solution:

 Public Shared Function GetNextWeekDay() As Date
    Dim value As Date = Date.Now
    Dim intHour As Integer
    Dim intMinute As Integer
    Dim intSecond As Integer


    intHour = 17
    intMinute = 0
    intSecond = 0

    Dim newdatetime As DateTime = New Date(value.Year, value.Month, value.Day, intHour, intMinute, intSecond)

    If DateTime.Now < newdatetime Then

        If value.DayOfWeek = DayOfWeek.Saturday Then
            value = value.AddDays(2)
            Return value
        End If

        If value.DayOfWeek = DayOfWeek.Sunday Then
            value = value.AddDays(1)
            Return value
        End If

        Return value

    ElseIf DateTime.Now > newdatetime Then
        Do
            value = value.AddDays(1)
        Loop While (value.DayOfWeek = DayOfWeek.Saturday) Or (value.DayOfWeek = DayOfWeek.Sunday)
        Return value
    End If
End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:45:52+00:00Added an answer on June 15, 2026 at 10:45 am

    As I understand your question, you are basically looking for a way to execute a program at a given time? If so, have a look at cron or the Windows scheduler, depending on the OS you are running this on.


    Update: So basically you just need to compare the current time and check whether it is before 5pm. Then you should have a function which return the data from 5pm current day until 5pm tomorrow.

    You might want to have a look at this VB tutorial for DateTime. Basically you need to compare the current time with a date time consisting of the current date at 5pm.


    Update: Just extend your if condition to also check that today is not Saturday or Sunday. Here’s a little code snippet I just whipped up. I am not really familiar with VB, so this might not be 100% correct, but I think you get the idea.

    Public Function GetNextWeekDay() As Date
        Dim value As Date = Date.Now
        Dim intHour As Integer
        Dim intMinute As Integer
        Dim intSecond As Integer
    
        intHour = 17
        intMinute = 0
        intSecond = 0
    
        Dim newdatetime As DateTime = New Date(value.Year, value.Month, value.Day, intHour, intMinute, intSecond)
    
        If value.DayOfWeek <> DayOfWeek.Saturday And value.DayOfWeek <> DayOfWeek.Sunday And DateTime.Now < newdatetime Then
            Return value.Date
        Else
            Do
                value = value.AddDays(1)
            Loop While (value.DayOfWeek = DayOfWeek.Saturday) Or (value.DayOfWeek = DayOfWeek.Sunday)
            Return value.Date
        End If
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Code: Public Shared Function DPLoadData() As String Dim s As
I have the following code: Public Shared Function GetAvailableManufacturers() As List(Of Manufacturer) 'first get
I have the following code: Public Shared Function GetListAsString(ByVal data As List(Of String)) As
I have code as following: Public Class xxxSvcHostFactory Inherits ServiceHostFactory Protected Overrides Function CreateServiceHost(ByVal
I have an ASP.NET PageMethod with the following signature: <WebMethod()> _ Public Shared Function
I have following code: public static void ProcessStep(Action action) { //do something here if
I have following code public class TEST { public static void main(String arg[]){ try
I have the following code: public void disconnect() { running = false; if(thread !=
I have the following code: public void Dispose() { bool append = true; using(var
I have the following code: public class Foo {} static class Program { [XmlElement(foo)]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.