|
| ||||||||||
| Tags: image, photo, picture, system date, visual studio express, vs 2008 |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Change image based on system date
Code: Me.MainLayoutPanel.BackgroundImage = Global.Management_Informative.My.Resources.Resources.plus_beautiful_band I would like to put an If to see whether it is summer and put the beach, if it is autumn then we put leaves and so on for all season. The problem is that I do not know the code to do so. Maybe it is menu that I compare the date that corresponds to my season but I do not know the code. |
|
#2
| ||||
| ||||
| Re: Change image based on system date
To do what? Do you know what season it is? Change the picture? The code to save an image you've posted. So I do not see what you lack For the season, just know the season dates: - Spring: March 21 - Summer: June 21 - Fall: September 21 - Winter: December 21 |
|
#3
| |||
| |||
| Re: Change image based on system date
Thank you for your reply. In fact I miss the code to retrieve the day and month (without the year) and the solution to compare date: How can I tell him: - If the system date is greater than 21/03 and less than the 21/06 so ... the rest I know. |
|
#4
| |||
| |||
| Re: Change image based on system date
To retrieve the month and day you just need your system time in a variable of type DateTime. Code: dim Dt as DateTime Dt.Day 'for the day Dt.month 'for the month Quote:
|
|
#5
| |||
| |||
| Re: Change image based on system date Code: Dim l_Date As DateTime l_Date.Day l_Date.Month Quote:
Code: If DateSystem > 21/03 and DateSystem < 21/06 Then
Me.MainLayoutPanel.BackgroundImage = Global.Management_Informative.My.Resources.Resources.image_of_spring
Else
If DateSystem > 21/06 and DateSystem < 21/12hen
Me.MainLayoutPanel.BackgroundImage = Global.Management_Informative.My.Resources.Resources.image_of_winter
End If
End If |
|
#6
| ||||
| ||||
| Re: Change image based on system date
This is a function that returns the season for a given date: Code: Public Enum Season
Spring
Summer
Autumn
Winter
End Enum
Public Shared Function GetSeason(ByVal dt As DateTime) As Season
Dim dSpring As DateTime = New DateTime(dt.Year, 3, 21)
Dim dSummer As DateTime = New DateTime(dt.Year, 6, 21)
Dim dAutumn As DateTime = New DateTime(dt.Year, 9, 21)
Dim dWinter As DateTime = New DateTime(dt.Year, 12, 21)
If dt < dSpring Then
Return Season.Winter
ElseIf dt < dSummer Then
Return Season.Spring
ElseIf dt < dAutumn Then
Return Season.Summer
ElseIf dt < dWinter Then
Return Season.Autumn
Else
Return Season.Winter
End If
End Function Code: Dim season As Season = GetSeason(DateTime.Today)
Select Case season
Case Season.Spring
Me.MainLayoutPanel.BackgroundImage = Global.Management_Informative.My.Resources.Resources.Spring
Case Season.Summer
Me.MainLayoutPanel.BackgroundImage = Global.Management_Informative.My.Resources.Resources.Summer
Case Season.Autumn
Me.MainLayoutPanel.BackgroundImage = Global.Management_Informative.My.Resources.Resources.Autumn
Case Season.Winter
Me.MainLayoutPanel.BackgroundImage = Global.Management_Informative.My.Resources.Resources.Winter
Case Else
' default case (should not occur...)
End Select |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Change image based on system date" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Script needed to Delete Files in a Directory Based on Date | adaher008 via WinServerKB.com | Windows Server Help | 11 | 02-01-2012 12:44 AM |
| Excel: How to make a list based on the date entered | OttaKoo | Windows Software | 5 | 31-03-2011 07:35 PM |
| Delete files based on creation date? | Hank Arnold (MVP) | Windows Server Help | 2 | 19-10-2010 12:55 AM |
| Select Unique Values (Selecting The Most Recent Record Based On Date) | Leeland | Software Development | 4 | 14-05-2010 12:16 AM |
| Create new folder and move files based on creation date | dstiff | Windows Server Help | 3 | 13-11-2009 04:04 AM |