Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Change image based on system date

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 12-12-2009
Member
 
Join Date: Jul 2009
Posts: 79
Change image based on system date
  

I created an app in visual studio express 2008. I set a screen for SplashScreen with an image. I would like this picture changes depending on the season, so I went to my SplashScreen designer and found the line that corresponds to the image display:

Code:
Me.MainLayoutPanel.BackgroundImage = Global.Management_Informative.My.Resources.Resources.plus_beautiful_band
Where plus_beautiful_band is the name of my image.

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.

Reply With Quote
  #2  
Old 12-12-2009
Member
 
Join Date: Feb 2008
Posts: 1,845
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
Reply With Quote
  #3  
Old 12-12-2009
Member
 
Join Date: Jul 2009
Posts: 79
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.
Reply With Quote
  #4  
Old 12-12-2009
Member
 
Join Date: Nov 2008
Posts: 1,192
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
and you can compare a Date1.CompareTo (date2)
Quote:
Date1.CompareTo (date2)
compares the value of this instance to a System.DateTime instance and returns an integer that indicates whether this instance is earlier, later or equal to the specified DateTime
Reply With Quote
  #5  
Old 12-12-2009
Member
 
Join Date: Jul 2009
Posts: 79
Re: Change image based on system date

Code:
Dim l_Date As DateTime
l_Date.Day
l_Date.Month
Visual Studio returns me the error:
Quote:
Standard access to the property must assign the property or use its value.
And after recovering my day and my month how I did for them together? Basically I want something like:
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
Except that it does not work. I'm not very good at programming, I do not understand everything
Reply With Quote
  #6  
Old 12-12-2009
Member
 
Join Date: Feb 2008
Posts: 1,845
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
To use it, you can do like this (assuming you had the resources in your application images Spring, Summer, Autumn and Winter):
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
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 02:22 AM.