Link to home
Start Free TrialLog in
Avatar of technicaltrader
technicaltraderFlag for United States of America

asked on

How to post a message 5 days a week only Visual basic 2008

Hi.

Example:
Using VB2008 Express, how would I go about posting a message "Lunch Time" in a TextBox or status bar at 12:00pm and stop the message at 1:00pm Monday - friday only.

I know how to use the timers for posting it for one hour, I don't know how to use the "Date method" as I have seen many refer to. Or best said, I do not know how to code for a message to appear at a set day of the week and time of the day.


Thank you in advance.

ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of technicaltrader

ASKER

Got the logic and making it work for me so far. Changing the date on my computer clock to check it. All is good. thank you!

This is how I used it so far:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventsArgs) handles timer1.Tick
Dim now As DateTime = DateTime.Now
        If Not (now.DayOfWeek = DayOfWeek.Saturday Or now.DayOfWeek = DayOfWeek.Sunday) Then
            StatusBar1.Text = "Lunch Time!"
        Else
            StatusBar1.Text = "Weekend!"
        End If


How is it that I control this to display message at specific times in the day with the day of the week? (Example: 12:00pm to 1:00pm)

Far as I know, I can only use the Timer to control the duration the message is displayed. So if duration is 1 hour I would set the Interval to 3,600,000. Don't know how to control the time of day part.

Thanks again!...
Shoot, didn't see your post guru_sami! I will try that suggestion first unless you see my last question and thought something different. Will try that suggestion too.

Thanks!
See Guru_Sami's comment.  It shows you with hour portion also.  Thought you already had that; therefore, I didn't post it.  And my "Weekend!" was just to make it clear what I was doing, in your case where you are showing a status OR not, String.Empty may work better for you which is also shown in Guru_Sami's comment.

Best regards,
Kevin
Thank you both. Loved the addition of the "Weekend!" message (Could tell some passion for the weekend too in that message! LOL) Believe this will get me on my way. Thank you so much!... I was stagnant in this solution quest.